PHP - parallel task runner -
i need parallel task runner in php (most on windows - iis7 fastcgi), has complete implementation hiding. interface should this:
$taskrunner = new paralleltaskrunner(); $taskrunner->add(function () use ($sharedresource){ //task 1 }); $taskrunner->add(function () use ($sharedresource){ //task 2 }); $taskrunner->run(); //runs task 1, task 2 parallel
i have done research: aware of techniques can run php code parallel - pthreads, pcntl, exec, gearman, curl multi, etc...
the questions need answer for:
- is possible make implementation hiding of these techniques? how possible (if there advanced workaround in implementation details)? there library has feature?
- how can extract information running of parallel tasks? example:
task1: { a(); b(); }
,task2: { c(); }
, how can know calling order of functionsa(); b(); c();
ora(); c(); b();
orc(); a(); b();
? - how can debug tasks if goes wrong?
update
i checked many possible solution, , ended pthreads. easier use threads processes... drawback not support xdebug.
promises in php pthreads
something wrote, have no time talk ...
promises delicious, make ordinarily rather complex simple.
everyone understands concept of stack when talk javascript; how animations, , lots of other fancy stuff on web, run.
in effect, effort write promises pthreads attempt make threading simple javascript stack, understands.
it happens thing suits needs perfectly:
$manager = new promisemanager(); $promise = new promise($manager, new calculatethemeaningoflife()); $promise ->then( new addtwo($promise)) ->then( new printmeaning($promise)); $manager->shutdown();
you have use objects , not closures (limitation of zend), promises pattern , async , managed.
this php, can installed composer ... if sort of thing ...
Comments
Post a Comment