diff --git a/src/TamerLib/Classes/WorkerSupervisor.php b/src/TamerLib/Classes/WorkerSupervisor.php index 3341a9e..6b1c1b1 100644 --- a/src/TamerLib/Classes/WorkerSupervisor.php +++ b/src/TamerLib/Classes/WorkerSupervisor.php @@ -11,7 +11,6 @@ use TamerLib\Objects\ServerConfiguration; use TamerLib\Objects\WorkerConfiguration; use TamerLib\Objects\WorkerInstance; - use TamerLib\tm; class WorkerSupervisor { @@ -37,8 +36,8 @@ /** * Generates a worker configuration object. * - * @param int $channel - * @return WorkerConfiguration + * @param int $channel The channel to use for the worker. + * @return WorkerConfiguration The generated worker configuration. */ private function generateWorkerConfiguration(int $channel=0): WorkerConfiguration { @@ -55,12 +54,12 @@ /** * Spawns a specified number of workers for a given path. * - * @param string $path - * @param int $count - * @param int $channel - * @param bool $check + * @param string $path Optional. The path to the worker file, defaults to subproc. + * @param int $count Optional. The number of workers to spawn, defaults to 8. + * @param int $channel Optional. The channel to use for the workers, defaults to 0. + * @param bool $check Optional. Whether to check if the workers have started, defaults to true. + * @throws WorkerFailedException Thrown if the worker fails to start. * @return void - * @throws WorkerFailedException */ public function spawnWorker(string $path, int $count=8, int $channel=0, bool $check=true): void { @@ -70,7 +69,6 @@ } Log::verbose(Utilities::getName(), sprintf('Spawning %s workers for %s', $count, $path)); - $spawned_workers = []; for($i = 0; $i < $count; $i++) @@ -91,9 +89,9 @@ /** * Checks if the workers have started. * - * @param array $workers + * @param array $workers The workers to check. + * @throws WorkerFailedException Thrown if the worker fails to start. * @return void - * @throws WorkerFailedException */ private function checkWorkers(array $workers): void { @@ -125,10 +123,10 @@ /** * Spawns a closure as a worker process. (built-in worker) * - * @param int $count - * @param int $channel + * @param int $count The number of workers to spawn. + * @param int $channel The channel to use for the workers. + * @throws WorkerFailedException Thrown if the worker fails to start. * @return void - * @throws WorkerFailedException */ public function spawnClosure(int $count=8, int $channel=0): void { @@ -145,6 +143,11 @@ */ public function printUpdates(): void { + if(count($this->workers) === 0) + { + return; + } + /** @var WorkerInstance $worker */ foreach($this->workers as $worker) { diff --git a/src/TamerLib/Classes/subproc b/src/TamerLib/Classes/subproc index 76759ea..5acb618 100644 --- a/src/TamerLib/Classes/subproc +++ b/src/TamerLib/Classes/subproc @@ -1,8 +1,8 @@ -