Added await all

This commit is contained in:
Joop Schilder 2019-01-16 16:53:44 +01:00
parent 78fdbfaa49
commit 8d1b772382
2 changed files with 24 additions and 4 deletions

View File

@ -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

View File

@ -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();
}
}