mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-03 16:45:13 +00:00
Mass removal of useless @param/@return PHPDoc annotations, pass 1
This commit is contained in:
@ -81,8 +81,6 @@ class AsyncPool{
|
||||
|
||||
/**
|
||||
* Returns the maximum size of the pool. Note that there may be less active workers than this number.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSize() : int{
|
||||
return $this->size;
|
||||
@ -90,8 +88,6 @@ class AsyncPool{
|
||||
|
||||
/**
|
||||
* Increases the maximum size of the pool to the specified amount. This does not immediately start new workers.
|
||||
*
|
||||
* @param int $newSize
|
||||
*/
|
||||
public function increaseSize(int $newSize) : void{
|
||||
if($newSize > $this->size){
|
||||
@ -104,8 +100,6 @@ class AsyncPool{
|
||||
* The signature should be `function(int $worker) : void`
|
||||
*
|
||||
* This function will call the hook for every already-running worker.
|
||||
*
|
||||
* @param \Closure $hook
|
||||
*/
|
||||
public function addWorkerStartHook(\Closure $hook) : void{
|
||||
Utils::validateCallableSignature(function(int $worker) : void{}, $hook);
|
||||
@ -117,8 +111,6 @@ class AsyncPool{
|
||||
|
||||
/**
|
||||
* Removes a previously-registered callback listening for workers being started.
|
||||
*
|
||||
* @param \Closure $hook
|
||||
*/
|
||||
public function removeWorkerStartHook(\Closure $hook) : void{
|
||||
unset($this->workerStartHooks[spl_object_hash($hook)]);
|
||||
@ -136,10 +128,6 @@ class AsyncPool{
|
||||
/**
|
||||
* Fetches the worker with the specified ID, starting it if it does not exist, and firing any registered worker
|
||||
* start hooks.
|
||||
*
|
||||
* @param int $worker
|
||||
*
|
||||
* @return AsyncWorker
|
||||
*/
|
||||
private function getWorker(int $worker) : AsyncWorker{
|
||||
if(!isset($this->workers[$worker])){
|
||||
@ -158,9 +146,6 @@ class AsyncPool{
|
||||
|
||||
/**
|
||||
* Submits an AsyncTask to an arbitrary worker.
|
||||
*
|
||||
* @param AsyncTask $task
|
||||
* @param int $worker
|
||||
*/
|
||||
public function submitTaskToWorker(AsyncTask $task, int $worker) : void{
|
||||
if($worker < 0 or $worker >= $this->size){
|
||||
@ -187,8 +172,6 @@ class AsyncPool{
|
||||
* - if an idle worker is found, it will be selected
|
||||
* - else, if the worker pool is not full, a new worker will be selected
|
||||
* - else, the worker with the smallest backlog is chosen.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function selectWorker() : int{
|
||||
$worker = null;
|
||||
@ -219,10 +202,6 @@ class AsyncPool{
|
||||
/**
|
||||
* Submits an AsyncTask to the worker with the least load. If all workers are busy and the pool is not full, a new
|
||||
* worker may be started.
|
||||
*
|
||||
* @param AsyncTask $task
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function submitTask(AsyncTask $task) : int{
|
||||
if($task->getTaskId() !== null){
|
||||
@ -236,9 +215,6 @@ class AsyncPool{
|
||||
|
||||
/**
|
||||
* Removes a completed or crashed task from the pool.
|
||||
*
|
||||
* @param AsyncTask $task
|
||||
* @param bool $force
|
||||
*/
|
||||
private function removeTask(AsyncTask $task, bool $force = false) : void{
|
||||
if(isset($this->taskWorkers[$task->getTaskId()])){
|
||||
|
@ -111,9 +111,6 @@ abstract class AsyncTask extends Collectable{
|
||||
return $this->cancelRun;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasResult() : bool{
|
||||
return $this->result !== null;
|
||||
}
|
||||
@ -128,8 +125,6 @@ abstract class AsyncTask extends Collectable{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $taskId
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setTaskId(int $taskId){
|
||||
@ -146,8 +141,6 @@ abstract class AsyncTask extends Collectable{
|
||||
/**
|
||||
* @see AsyncWorker::getFromThreadStore()
|
||||
*
|
||||
* @param string $identifier
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getFromThreadStore(string $identifier){
|
||||
@ -160,7 +153,6 @@ abstract class AsyncTask extends Collectable{
|
||||
/**
|
||||
* @see AsyncWorker::saveToThreadStore()
|
||||
*
|
||||
* @param string $identifier
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return void
|
||||
@ -174,10 +166,6 @@ abstract class AsyncTask extends Collectable{
|
||||
|
||||
/**
|
||||
* @see AsyncWorker::removeFromThreadStore()
|
||||
*
|
||||
* @param string $identifier
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeFromThreadStore(string $identifier) : void{
|
||||
if($this->worker === null or $this->isGarbage()){
|
||||
@ -197,8 +185,6 @@ abstract class AsyncTask extends Collectable{
|
||||
* Actions to execute when completed (on main thread)
|
||||
* Implement this if you want to handle the data in your AsyncTask after it has been processed
|
||||
*
|
||||
* @param Server $server
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function onCompletion(Server $server){
|
||||
@ -220,8 +206,6 @@ abstract class AsyncTask extends Collectable{
|
||||
/**
|
||||
* @internal Only call from AsyncPool.php on the main thread
|
||||
*
|
||||
* @param Server $server
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function checkProgressUpdates(Server $server){
|
||||
@ -236,7 +220,6 @@ abstract class AsyncTask extends Collectable{
|
||||
* All {@link AsyncTask::publishProgress} calls should result in {@link AsyncTask::onProgressUpdate} calls before
|
||||
* {@link AsyncTask::onCompletion} is called.
|
||||
*
|
||||
* @param Server $server
|
||||
* @param mixed $progress The parameter passed to {@link AsyncTask::publishProgress}. It is serialize()'ed
|
||||
* and then unserialize()'ed, as if it has been cloned.
|
||||
*
|
||||
@ -336,7 +319,6 @@ abstract class AsyncTask extends Collectable{
|
||||
|
||||
/**
|
||||
* @internal Called by the AsyncPool to destroy any leftover stored objects that this task failed to retrieve.
|
||||
* @return bool
|
||||
*/
|
||||
public function removeDanglingStoredObjects() : bool{
|
||||
if(self::$localObjectStorage !== null and isset(self::$localObjectStorage[$this])){
|
||||
|
@ -98,7 +98,6 @@ class AsyncWorker extends Worker{
|
||||
* Saves mixed data into the worker's thread-local object store. This can be used to store objects which you
|
||||
* want to use on this worker thread from multiple AsyncTasks.
|
||||
*
|
||||
* @param string $identifier
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function saveToThreadStore(string $identifier, $value) : void{
|
||||
@ -113,8 +112,6 @@ class AsyncWorker extends Worker{
|
||||
*
|
||||
* Objects stored in this storage may ONLY be retrieved while the task is running.
|
||||
*
|
||||
* @param string $identifier
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getFromThreadStore(string $identifier){
|
||||
@ -123,8 +120,6 @@ class AsyncWorker extends Worker{
|
||||
|
||||
/**
|
||||
* Removes previously-stored mixed data from the worker's thread-local object store.
|
||||
*
|
||||
* @param string $identifier
|
||||
*/
|
||||
public function removeFromThreadStore(string $identifier) : void{
|
||||
unset(self::$store[$identifier]);
|
||||
|
@ -44,7 +44,6 @@ class BulkCurlTask extends AsyncTask{
|
||||
* "timeout", "extraHeaders" and "extraOpts". Documentation of these options are same as those in
|
||||
* {@link Utils::simpleCurl}.
|
||||
*
|
||||
* @param array $operations
|
||||
* @param mixed|null $complexData
|
||||
*/
|
||||
public function __construct(array $operations, $complexData = null){
|
||||
|
@ -37,11 +37,6 @@ class DumpWorkerMemoryTask extends AsyncTask{
|
||||
/** @var int */
|
||||
private $maxStringSize;
|
||||
|
||||
/**
|
||||
* @param string $outputFolder
|
||||
* @param int $maxNesting
|
||||
* @param int $maxStringSize
|
||||
*/
|
||||
public function __construct(string $outputFolder, int $maxNesting, int $maxStringSize){
|
||||
$this->outputFolder = $outputFolder;
|
||||
$this->maxNesting = $maxNesting;
|
||||
|
@ -35,9 +35,7 @@ class FileWriteTask extends AsyncTask{
|
||||
private $flags;
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param mixed $contents
|
||||
* @param int $flags
|
||||
*/
|
||||
public function __construct(string $path, $contents, int $flags = 0){
|
||||
$this->path = $path;
|
||||
|
@ -49,11 +49,6 @@ class SendUsageTask extends AsyncTask{
|
||||
/** @var string */
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* @param Server $server
|
||||
* @param int $type
|
||||
* @param array $playerList
|
||||
*/
|
||||
public function __construct(Server $server, int $type, array $playerList = []){
|
||||
$endpoint = "http://" . $server->getProperty("anonymous-statistics.host", "stats.pocketmine.net") . "/";
|
||||
|
||||
|
@ -37,9 +37,6 @@ abstract class Task{
|
||||
return $this->taskHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
final public function getTaskId() : int{
|
||||
if($this->taskHandler !== null){
|
||||
return $this->taskHandler->getTaskId();
|
||||
@ -53,8 +50,6 @@ abstract class Task{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TaskHandler|null $taskHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
final public function setHandler(TaskHandler $taskHandler = null){
|
||||
@ -66,8 +61,6 @@ abstract class Task{
|
||||
/**
|
||||
* Actions to execute when run
|
||||
*
|
||||
* @param int $currentTick
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract public function onRun(int $currentTick);
|
||||
|
@ -54,13 +54,6 @@ class TaskHandler{
|
||||
/** @var string */
|
||||
private $ownerName;
|
||||
|
||||
/**
|
||||
* @param Task $task
|
||||
* @param int $taskId
|
||||
* @param int $delay
|
||||
* @param int $period
|
||||
* @param string|null $ownerName
|
||||
*/
|
||||
public function __construct(Task $task, int $taskId, int $delay = -1, int $period = -1, ?string $ownerName = null){
|
||||
$this->task = $task;
|
||||
$this->taskId = $taskId;
|
||||
@ -72,67 +65,41 @@ class TaskHandler{
|
||||
$this->task->setHandler($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isCancelled() : bool{
|
||||
return $this->cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getNextRun() : int{
|
||||
return $this->nextRun;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $ticks
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setNextRun(int $ticks){
|
||||
$this->nextRun = $ticks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTaskId() : int{
|
||||
return $this->taskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Task
|
||||
*/
|
||||
public function getTask() : Task{
|
||||
return $this->task;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDelay() : int{
|
||||
return $this->delay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDelayed() : bool{
|
||||
return $this->delay > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isRepeating() : bool{
|
||||
return $this->period > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPeriod() : int{
|
||||
return $this->period;
|
||||
}
|
||||
@ -159,8 +126,6 @@ class TaskHandler{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $currentTick
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run(int $currentTick){
|
||||
@ -172,9 +137,6 @@ class TaskHandler{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTaskName() : string{
|
||||
return $this->taskName;
|
||||
}
|
||||
|
@ -54,7 +54,6 @@ class TaskScheduler{
|
||||
|
||||
/**
|
||||
* @param \Logger $logger @deprecated
|
||||
* @param null|string $owner
|
||||
*/
|
||||
public function __construct(\Logger $logger, ?string $owner = null){
|
||||
$this->owner = $owner;
|
||||
@ -62,8 +61,6 @@ class TaskScheduler{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Task $task
|
||||
*
|
||||
* @return TaskHandler
|
||||
*/
|
||||
public function scheduleTask(Task $task){
|
||||
@ -71,9 +68,6 @@ class TaskScheduler{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Task $task
|
||||
* @param int $delay
|
||||
*
|
||||
* @return TaskHandler
|
||||
*/
|
||||
public function scheduleDelayedTask(Task $task, int $delay){
|
||||
@ -81,9 +75,6 @@ class TaskScheduler{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Task $task
|
||||
* @param int $period
|
||||
*
|
||||
* @return TaskHandler
|
||||
*/
|
||||
public function scheduleRepeatingTask(Task $task, int $period){
|
||||
@ -91,10 +82,6 @@ class TaskScheduler{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Task $task
|
||||
* @param int $delay
|
||||
* @param int $period
|
||||
*
|
||||
* @return TaskHandler
|
||||
*/
|
||||
public function scheduleDelayedRepeatingTask(Task $task, int $delay, int $period){
|
||||
@ -102,8 +89,6 @@ class TaskScheduler{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $taskId
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function cancelTask(int $taskId){
|
||||
@ -130,20 +115,11 @@ class TaskScheduler{
|
||||
$this->ids = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $taskId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isQueued(int $taskId) : bool{
|
||||
return isset($this->tasks[$taskId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Task $task
|
||||
* @param int $delay
|
||||
* @param int $period
|
||||
*
|
||||
* @return TaskHandler
|
||||
*
|
||||
* @throws \InvalidStateException
|
||||
@ -190,8 +166,6 @@ class TaskScheduler{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $currentTick
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function mainThreadHeartbeat(int $currentTick){
|
||||
@ -218,9 +192,6 @@ class TaskScheduler{
|
||||
return !$this->queue->isEmpty() and $this->queue->current()->getNextRun() <= $currentTick;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
private function nextId() : int{
|
||||
return $this->ids++;
|
||||
}
|
||||
|
Reference in New Issue
Block a user