public function flushProcesses($flags = Runtime::DESTROY_KEEP)
{
$promises = [];
if ($flags === Runtime::DESTROY_KEEP) {
return Promise::doReject(new RejectionException('Process storage could not be flushed because of force level set to DESTROY_KEEP.'));
}
foreach ($this->processes as $alias => $process) {
$promises[] = $this->destroyProcess($alias, $flags);
}
return Promise::all($promises)->then(function () {
$this->processes = [];
$this->updateStorage();
return 'Processes storage has been flushed.';
});
}