Edit report at https://bugs.php.net/bug.php?id=46919&edit=1
ID: 46919 Comment by: invictible at live dot co dot uk 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 Block user comment: N Private report: N New Comment: I believe, that this would be a excellant addition to PHP as I've run into many situation where multi-threading would have made it much more performant than simply running everything in one thread where a single function taking it's time or other lengthy tasks can have a significant impact on the time it takes the script to run. Previous Comments: ------------------------------------------------------------------------ [2012-03-21 22:09:47] jose dot nobile at gmail dot com How many year the PHP community will wait for <?PHP new Thread?> ------------------------------------------------------------------------ [2010-04-01 15:05:55] speedy dot spam at gmail dot com 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. ------------------------------------------------------------------------ [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 https://bugs.php.net/bug.php?id=46919&edit=1