Example #1
0
while (++$o < 20) {
    /* items stacked could be using resources available in worker */
    $work[] = new MyWork($storage);
}
foreach ($work as $w) {
    $worker->stack($w);
}
/*
	In this example your application would now be loaded, with access to a runnng background worker
	and all the other goodies we just created/initiated/whatever
	It's worth noting that now any part of your normal application code can stack to the worker, and reference the global storage
	or whatever else you created...
	It does not matter what reference you pass around.
*/
/* done with worker, execute everything */
$worker->shutdown();
printf("set by stackables...:\n");
foreach ($work as $w) {
    var_dump($storage->fetch($w->getStorageId()));
}
printf("set by threads executed by stackables executing in a worker: ...\n");
foreach ($work as $w) {
    if ($w->getThreadStorageId()) {
        var_dump($storage->fetch($w->getThreadStorageId()));
    }
}
printf("set by the worker (alt syntax):\n");
var_dump($storage->fetch("GlobalWorker"));
/* 
	@NOTE pretty cool, right ?
*/