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
|
||||
*/
|
||||
@ -199,10 +211,7 @@ class Asynchronous
|
||||
* ensure that all writing to the shared
|
||||
* memory block is finished.
|
||||
*/
|
||||
while (count($instance->children) > 0) {
|
||||
pcntl_wait($status);
|
||||
array_shift($instance->children);
|
||||
}
|
||||
self::awaitChildren();
|
||||
|
||||
/*
|
||||
* Ask the kernel to mark the shared memory
|
||||
|
@ -25,3 +25,14 @@ if (!function_exists('async_cleanup')) {
|
||||
Asynchronous::cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('async_await_all')) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function async_await_all()
|
||||
{
|
||||
Asynchronous::awaitChildren();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user