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.
If you know how to write phpt tests, please open a PR with environment information, and your test, this will cause CI to test your issue before a human is able to look
Environment
PHP: 5.6.14
pthreads: 2.0.10
OS: Mac OS X 10.11.5
Summary
When passing a thread object in worker to other methods, their first sibling in the worker stack is passed.
Reproducing Code
<?phpclassInventoryextendsThreaded
{
private$queue;
publicfunction__construct(Threaded$queue)
{
$this->queue = $queue;
}
publicfunctionput(Thread$producer, $product)
{
$this->queue[] = $product;
printf("[%s] instance [%s] in worker [%s] is producing now ...\n\n", get_class($producer), $producer->name, $producer->worker->name);
}
}
classProducerFooextendsThread
{
private$name;
publicfunction__construct($name)
{
$this->name = $name;
}
publicfunctionrun()
{
printf("[ProducerFoo] [%s] in worker [%s] is about to run ...\n", $this->name, $this->worker->name);
$this->worker->inventory->put($this, '*');
}
}
classProducerBarextendsThread
{
private$name;
publicfunction__construct($name)
{
$this->name = $name;
}
publicfunctionrun()
{
printf("[ProducerBar] [%s] in worker [%s] is about to run ...\n", $this->name, $this->worker->name);
$this->worker->inventory->put($this, '*');
}
}
$queue = newThreaded();
$inventory = newInventory($queue);
$p1 = newProducerFoo('p1');
$p2 = newProducerFoo('p2');
$p3 = newProducerBar('p3');
$worker = newWorker();
$worker->inventory = $inventory;
$worker->name = "w1";
$worker->stack($p1);
$worker->stack($p2);
$worker->stack($p3);
$worker->start();
$worker->shutdown();
Expected Output
[ProducerFoo] [p1] in worker [w1] is about to run ...
[ProducerFoo] instance [p1] in worker [w1] is producing now ...
[ProducerFoo] [p2] in worker [w1] is about to run ...
[ProducerFoo] instance [p1] in worker [w1] is producing now ...
[ProducerBar] [p3] in worker [w1] is about to run ...
[ProducerBar] instance [p3] in worker [w1] is producing now ...
Actual Output
[ProducerFoo] [p1] in worker [w1] is about to run ...
[ProducerFoo] instance [p1] in worker [w1] is producing now ...
[ProducerFoo] [p2] in worker [w1] is about to run ...
[ProducerFoo] instance [p1] in worker [w1] is producing now ...
[ProducerBar] [p3] in worker [w1] is about to run ...
[ProducerFoo] instance [p1] in worker [w1] is producing now ...
The text was updated successfully, but these errors were encountered:
zerustech
changed the title
Worker does not pass stacked objects with correct property values
When passing a thread object in worker to other methods, their first sibling in the stack is passed
Jun 20, 2016
If you know how to write phpt tests, please open a PR with environment information, and your test, this will cause CI to test your issue before a human is able to look
Environment
Summary
When passing a thread object in worker to other methods, their first sibling in the worker stack is passed.
Reproducing Code
Expected Output
Actual Output
The text was updated successfully, but these errors were encountered: