ko-process icon indicating copy to clipboard operation
ko-process copied to clipboard

Additional Parameter

Open fri13th opened this issue 7 years ago • 2 comments

I needed some additional parameter when starting thread. So I added it in Process class and fork and spawn method in ProcessManager class. I don' have enough time to PR, now. So I just leave an issue here.

$param = "whatever";

$process = $manager->fork(function(Ko\Process $p, $param) {
    // do something
}, $param);

source.zip

fri13th avatar Mar 15 '17 03:03 fri13th

If you need to use other variables in the fork Closure scope use "use()"

$params = ['foo', 'bar'];                          
$manager->fork(function (\Ko\Process $jobProcess) use ($params) {
    //do something
});

othercodes avatar Apr 02 '18 09:04 othercodes

Thank you for your kind reply. Actually there was some legacy issue, so I couldn't use "use()". but now I don't care about PHP 5.3.

fri13th avatar Apr 02 '18 09:04 fri13th