What is happening here
Explicable and avoidable ...
https://gist.github.com/krakjoe/6437782
So we do not do the done thing; in a pthreads application, you are responsible for the objects you create, you are also responsible for retaining a reference to objects that are going to be executed, or accessed from other executing contexts, until that execution or access has taken place.
This applies as much to shutdown time as it does to runtime, what is happening here is that Zend is shutting down and destroying the Work variable before it is executed, even though you retain a reference.
You must force the worker to synchronize with the current thread by joining with it, Worker::shutdown
will solve the problem.
<?php
class Work extends Stackable
{
public function run ()
{
echo "test"
}
}
$my = new Worker();
$work = new Work();
$my->start();
$my->stack($work);
$my->shutdown();
?>