Fix bug with static closures

This commit is contained in:
Aaron Piotrowski 2015-08-27 14:49:41 -05:00
parent c7dbf7394f
commit 7b2334f0d0
2 changed files with 13 additions and 7 deletions

View File

@ -80,7 +80,7 @@ class Fork implements ContextInterface
*/
public function isRunning()
{
return 0 !== $this->pid && posix_getpgid($this->pid) !== false;
return 0 !== $this->pid && false !== posix_getpgid($this->pid);
}
/**
@ -146,9 +146,12 @@ class Fork implements ContextInterface
$executor = new ForkExecutor($this->synchronized, $channel);
try {
$function = $this->function;
if ($function instanceof \Closure) {
$function = $function->bindTo($executor, ForkExecutor::class);
if ($this->function instanceof \Closure) {
$function = $this->function->bindTo($executor, ForkExecutor::class);
}
if (empty($function)) {
$function = $this->function;
}
$result = new ExitSuccess(yield call_user_func_array($function, $this->args));

View File

@ -120,9 +120,12 @@ class InternalThread extends \Thread
$executor = new ThreadExecutor($this, $channel);
try {
$function = $this->function;
if ($function instanceof \Closure) {
$function = $function->bindTo($executor, ThreadExecutor::class);
if ($this->function instanceof \Closure) {
$function = $this->function->bindTo($executor, ThreadExecutor::class);
}
if (empty($function)) {
$function = $this->function;
}
$result = new ExitSuccess(yield call_user_func_array($function, $this->args));