Edit report at http://bugs.php.net/bug.php?id=46919&edit=1

 ID:               46919
 Comment by:       speedy dot spam at gmail dot com
 Reported by:      n0valyfe at gamergrid dot net
 Summary:          Multi threading
 Status:           Open
 Type:             Feature/Change Request
 Package:          Feature/Change Request
 Operating System: All
 PHP Version:      5.2.8

 New Comment:

What would be really great to have is something similar to classic
pcntl_clone() linux kernel function on the PHP level, accepting a
function to be executed as a parameter and sharing all the
variables/state with the primary and other created threads.



Locking could be done with a simple and optional use of mutexes on the
application level, if one needs to view fully consistent state of a
certain variable / array. (ie. otherwise, foreach() loop while writing
to an array in the other thread might not see some recently added
entries)



As an idea, on the internal implementation side, copy-on-write semantics
could be used with read-only operations seeing the previous version
while the write/modify operation is executed on a copy.



Even if unstable at first (marked as experimental or some such), it
would be a good starting point for making PHP thread-safe, re-entrant,
and multi-core compatible.


Previous Comments:
------------------------------------------------------------------------
[2008-12-21 19:39:34] n0valyfe at gamergrid dot net

Description:
------------
Would it be possible to add some sort of multithreading into PHP, say a
new thread is created via a function, to execute a function or object
method in a new thread.



Keeping the scope intact, so that $this and global vars work inside that
function in another thread.



I think this would benefit PHP in many ways, for instance a script
wouldnt "hang" when executing something that can take a while, it can
just open a new thread.



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=46919&edit=1

Reply via email to