mirror of
https://github.com/amphp/parallel.git
synced 2025-02-24 06:42:26 +01:00
Fix bug with static closures
This commit is contained in:
parent
c7dbf7394f
commit
7b2334f0d0
@ -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));
|
||||
|
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user