mirror of
https://github.com/amphp/parallel.git
synced 2025-02-24 14:52:25 +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()
|
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);
|
$executor = new ForkExecutor($this->synchronized, $channel);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$function = $this->function;
|
if ($this->function instanceof \Closure) {
|
||||||
if ($function instanceof \Closure) {
|
$function = $this->function->bindTo($executor, ForkExecutor::class);
|
||||||
$function = $function->bindTo($executor, ForkExecutor::class);
|
}
|
||||||
|
|
||||||
|
if (empty($function)) {
|
||||||
|
$function = $this->function;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = new ExitSuccess(yield call_user_func_array($function, $this->args));
|
$result = new ExitSuccess(yield call_user_func_array($function, $this->args));
|
||||||
|
@ -120,9 +120,12 @@ class InternalThread extends \Thread
|
|||||||
$executor = new ThreadExecutor($this, $channel);
|
$executor = new ThreadExecutor($this, $channel);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$function = $this->function;
|
if ($this->function instanceof \Closure) {
|
||||||
if ($function instanceof \Closure) {
|
$function = $this->function->bindTo($executor, ThreadExecutor::class);
|
||||||
$function = $function->bindTo($executor, ThreadExecutor::class);
|
}
|
||||||
|
|
||||||
|
if (empty($function)) {
|
||||||
|
$function = $this->function;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = new ExitSuccess(yield call_user_func_array($function, $this->args));
|
$result = new ExitSuccess(yield call_user_func_array($function, $this->args));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user