diff --git a/src/scheduler/AsyncPool.php b/src/scheduler/AsyncPool.php index 047488ee3..645dfc24c 100644 --- a/src/scheduler/AsyncPool.php +++ b/src/scheduler/AsyncPool.php @@ -163,7 +163,7 @@ class AsyncPool{ * Submits an AsyncTask to an arbitrary worker. */ public function submitTaskToWorker(AsyncTask $task, int $worker) : void{ - if($worker < 0 or $worker >= $this->size){ + if($worker < 0 || $worker >= $this->size){ throw new \InvalidArgumentException("Invalid worker $worker"); } if($task->isSubmitted()){ @@ -197,7 +197,7 @@ class AsyncPool{ } } } - if($worker === null or ($minUsage > 0 and count($this->workers) < $this->size)){ + if($worker === null || ($minUsage > 0 && count($this->workers) < $this->size)){ //select a worker to start on the fly for($i = 0; $i < $this->size; ++$i){ if(!isset($this->workers[$i])){ @@ -297,7 +297,7 @@ class AsyncPool{ $ret = 0; $time = time(); foreach($this->taskQueues as $i => $queue){ - if((!isset($this->workerLastUsed[$i]) or $this->workerLastUsed[$i] + 300 < $time) and $queue->isEmpty()){ + if((!isset($this->workerLastUsed[$i]) || $this->workerLastUsed[$i] + 300 < $time) && $queue->isEmpty()){ $this->workers[$i]->quit(); $this->eventLoop->removeNotifier($this->workers[$i]->getNotifier()); unset($this->workers[$i], $this->taskQueues[$i], $this->workerLastUsed[$i]); diff --git a/src/scheduler/AsyncTask.php b/src/scheduler/AsyncTask.php index 2f1bedc6b..ea70364b9 100644 --- a/src/scheduler/AsyncTask.php +++ b/src/scheduler/AsyncTask.php @@ -93,7 +93,7 @@ abstract class AsyncTask extends \Threaded{ } public function isCrashed() : bool{ - return $this->crashed or $this->isTerminated(); + return $this->crashed || $this->isTerminated(); } /** @@ -101,7 +101,7 @@ abstract class AsyncTask extends \Threaded{ * because it is not true prior to task execution. */ public function isFinished() : bool{ - return $this->finished or $this->isCrashed(); + return $this->finished || $this->isCrashed(); } public function hasResult() : bool{ @@ -236,7 +236,7 @@ abstract class AsyncTask extends \Threaded{ */ protected function fetchLocal(string $key){ $id = spl_object_id($this); - if(self::$threadLocalStorage === null or !isset(self::$threadLocalStorage[$id][$key])){ + if(self::$threadLocalStorage === null || !isset(self::$threadLocalStorage[$id][$key])){ throw new \InvalidArgumentException("No matching thread-local data found on this thread"); } @@ -245,7 +245,7 @@ abstract class AsyncTask extends \Threaded{ final public function __destruct(){ $this->reallyDestruct(); - if(self::$threadLocalStorage !== null and isset(self::$threadLocalStorage[$h = spl_object_id($this)])){ + if(self::$threadLocalStorage !== null && isset(self::$threadLocalStorage[$h = spl_object_id($this)])){ unset(self::$threadLocalStorage[$h]); if(self::$threadLocalStorage->count() === 0){ self::$threadLocalStorage = null; diff --git a/src/scheduler/Task.php b/src/scheduler/Task.php index 0c4ea4469..4ad4c7e39 100644 --- a/src/scheduler/Task.php +++ b/src/scheduler/Task.php @@ -42,7 +42,7 @@ abstract class Task{ } final public function setHandler(?TaskHandler $taskHandler) : void{ - if($this->taskHandler === null or $taskHandler === null){ + if($this->taskHandler === null || $taskHandler === null){ $this->taskHandler = $taskHandler; } } diff --git a/src/scheduler/TaskScheduler.php b/src/scheduler/TaskScheduler.php index a1ed6a261..f66bd857a 100644 --- a/src/scheduler/TaskScheduler.php +++ b/src/scheduler/TaskScheduler.php @@ -150,6 +150,6 @@ class TaskScheduler{ } private function isReady(int $currentTick) : bool{ - return !$this->queue->isEmpty() and $this->queue->current()->getNextRun() <= $currentTick; + return !$this->queue->isEmpty() && $this->queue->current()->getNextRun() <= $currentTick; } }