You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.
Tasks are submitted to the workers in a round robin fashion, so task 2 gets submitted to the same worker as task 0. If you need a custom algorithm, you need to use a custom pool implementation.
yes, I've made a custom implementation with queues. In my opinion the tasks should be submitted round robin only to free workers and not all. This way workers that complete before can process more tasks
Hi,
I've the same problem reported here:
https://stackoverflow.com/questions/54217345/php-multi-threading-and-pools
Basically I've php 7.2.19 with zts enabled:
[root@server tmp]# php -i | grep -i thread
/etc/php-zts.d/pthreads.ini
Thread Safety => enabled
pthreads
[root@server tmp]# php -v
PHP 7.2.19 (cli) (built: May 29 2019 11:10:45) ( ZTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.19, Copyright (c) 1999-2018, by Zend Technologies
I've the same problem both on Windows10 and CentOS7, so it's not OS related.
If I run this code:
$pool = new Pool(2);
foreach ([0,1,2,3] as $count) {
$pool->submit(
new class ($count) extends Threaded
{
private $count;
}
while ($pool->collect());
$pool->shutdown();
I get as output:
1 is ready
3 is ready
0 is ready
2 is ready
While I would expect that "0 is ready" is printed as last row, because "2 is ready" should be worked by first Worker not doing the sleep.
Where is the mistake and how to create a real POOL model where there are not free workers while there are tasks in queue?
Thank you
The text was updated successfully, but these errors were encountered: