Added await all
This commit is contained in:
parent
78fdbfaa49
commit
8d1b772382
@ -97,6 +97,18 @@ class Asynchronous
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function awaitChildren()
|
||||||
|
{
|
||||||
|
$instance = self::getInstance();
|
||||||
|
while (count($instance->children) > 0) {
|
||||||
|
pcntl_wait($status);
|
||||||
|
array_shift($instance->children);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
@ -199,10 +211,7 @@ class Asynchronous
|
|||||||
* ensure that all writing to the shared
|
* ensure that all writing to the shared
|
||||||
* memory block is finished.
|
* memory block is finished.
|
||||||
*/
|
*/
|
||||||
while (count($instance->children) > 0) {
|
self::awaitChildren();
|
||||||
pcntl_wait($status);
|
|
||||||
array_shift($instance->children);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ask the kernel to mark the shared memory
|
* Ask the kernel to mark the shared memory
|
||||||
|
@ -25,3 +25,14 @@ if (!function_exists('async_cleanup')) {
|
|||||||
Asynchronous::cleanup();
|
Asynchronous::cleanup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!function_exists('async_await_all')) {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function async_await_all()
|
||||||
|
{
|
||||||
|
Asynchronous::awaitChildren();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user