mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 16:24:05 +00:00
Replace disallowed operators in src/scheduler/
This commit is contained in:
parent
03f47d0a78
commit
b85fe0e72a
@ -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]);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user