Adding Multi-Threading to PHP (Purely New Idea Try it)

Coding Critique is the place to post source code for peer review by other members of DevNetwork. Any kind of code can be posted. Code posted does not have to be limited to PHP. All members are invited to contribute constructive criticism with the goal of improving the code. Posted code should include some background information about it and what areas you specifically would like help with.

Popular code excerpts may be moved to "Code Snippets" by the moderators.

Moderator: General Moderators

ASDen
Forum Commoner
Posts: 55
Joined: Fri Aug 24, 2007 10:27 am

Post by ASDen »

I released a version Containing all above Modifications with Ajax/Sockets & TextFiles/MySql
you can get it :
here : http://sourceforge.net/project/showfile ... _id=549135
Or here http://www.phpclasses.org/browse/package/4082.html
ASDen
Forum Commoner
Posts: 55
Joined: Fri Aug 24, 2007 10:27 am

Post by ASDen »

nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

Not that I want to re-open this can of worms, but our issue with your software was not it's functionality, it is with your naming of it (i.e. it's not multi-threading)


Congratulations on your award.
ASDen
Forum Commoner
Posts: 55
Joined: Fri Aug 24, 2007 10:27 am

Re: Adding Multi-Threading to PHP (Purely New Idea Try it)

Post by ASDen »

Hello everybody :D
it's been around 9 months since the last update to class and finally i got time to it
PHPThreader 1.6 Released
you can get it from sf here : http://sourceforge.net/project/showfile ... _id=203377
or from phpclasses here : http://www.phpclasses.org/browse/package/4082.html
---
The new version has the following features :-
1)Full Online Documentation of class here : http://ajphpth.sourceforge.net [An offline version is provided in sf]
2)new Communication Class : Shared Memory (shmop required )
3)new Thread Calling Class : CliThread (using shell calls) [for whoever asked , it can now run from PHP/Cli :P ]
4)new Abstract Mutex Class which can be used from user defined Communication Clases .
5)new automatic System of thread watching
6) a simple loader to overcome path issues
7)new methods like Join()
---
hope to hear from you about it
Thanks
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Adding Multi-Threading to PHP (Purely New Idea Try it)

Post by josh »

I like the idea because it is thinking outside the box,

the only problem I have with it in theory is that youre launching more httpd threads on the server, and sending more overhead in the http requests. I don't think it would be practical performance wise but it definitely has its applications if you're willing to think out of hte box a little ;-)

Some of the best innovators in our history were laughed at when they proposed their ideas initially. I think this could be good where you have a view divided into multiple views, and you need to update different views at different intervals, without reloading the whole display for instance. Didn't download your code but you could also have your "threads" act as persistent servers, so the scripts could create "threads" within javascript as well.

A different idea would be to have a standalone script for your "thread" manager and have it call itself using the "nohup" utility in linux, runing on CLI

nohup is a Unix command that is used to run another command while suppressing the action of the HUP (hangup) signal, enabling the command to keep running after the user who issues the command has logged out. It is most often used to run commands in the background as daemons. Output that would normally go to the terminal goes to a file called nohup.out if it has not already been redirected.

You could even have your output redirected somewhere so the main thread can view the status of it's "child" threads
Post Reply