php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69542 Unexpected collect result from Pool
Submitted: 2015-04-28 10:25 UTC Modified: 2017-04-02 15:31 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: djmon84 at gmail dot com Assigned:
Status: Not a bug Package: pthreads (PECL)
PHP Version: 5.6.8 OS: CentOs 6.6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: djmon84 at gmail dot com
New email:
PHP Version: OS:

 

 [2015-04-28 10:25 UTC] djmon84 at gmail dot com
Description:
------------
I'm using the last version of the package: 2.0.10
The "collect" method returns elements in wrong order, always overwrites the first result with the last result.

Test script:
---------------
class job extends Collectable
{
	public $val;

	public function __construct($val){
    	    $this->val = $val;
	}
	public function run(){
	    'started ' .$this->val . PHP_EOL;    
	    sleep(1);
	    'finished ' .$this->val . PHP_EOL;		
	    $this->setGarbage();
	}
}

$p = new Pool(1);

$tasks = array(
    new job('job1'),
    new job('job2'),
    new job('job3'),
    new job('job4'),
    new job('job5')
);

foreach ($tasks as $task)
    $p->submit($task);

$p->shutdown();

$p->collect(function($checkingTask){
   $checkingTask->val;
});

Expected result:
----------------
job1
job2
job3
job4
job5

Actual result:
--------------
job5
job2
job3
job4
job5

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-04-02 15:31 UTC] tpunt@php.net
-Status: Open +Status: Not a bug
 [2017-04-02 15:31 UTC] tpunt@php.net
The collect method is not deterministic, and so it cannot be relied upon for retrieving data from a pool.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 10:01:26 2024 UTC