AsyncPool: added some void typehints

This commit is contained in:
Dylan K. Taylor 2018-06-11 10:41:40 +01:00
parent 4c98d9d3ad
commit 17607b8116

View File

@ -81,7 +81,7 @@ class AsyncPool{
* *
* @param int $newSize * @param int $newSize
*/ */
public function increaseSize(int $newSize){ public function increaseSize(int $newSize) : void{
if($newSize > $this->size){ if($newSize > $this->size){
$this->size = $newSize; $this->size = $newSize;
} }
@ -149,7 +149,7 @@ class AsyncPool{
* @param AsyncTask $task * @param AsyncTask $task
* @param int $worker * @param int $worker
*/ */
public function submitTaskToWorker(AsyncTask $task, int $worker){ public function submitTaskToWorker(AsyncTask $task, int $worker) : void{
if($worker < 0 or $worker >= $this->size){ if($worker < 0 or $worker >= $this->size){
throw new \InvalidArgumentException("Invalid worker $worker"); throw new \InvalidArgumentException("Invalid worker $worker");
} }
@ -213,7 +213,7 @@ class AsyncPool{
* @param AsyncTask $task * @param AsyncTask $task
* @param bool $force * @param bool $force
*/ */
private function removeTask(AsyncTask $task, bool $force = false){ private function removeTask(AsyncTask $task, bool $force = false) : void{
if(isset($this->taskWorkers[$task->getTaskId()])){ if(isset($this->taskWorkers[$task->getTaskId()])){
if(!$force and ($task->isRunning() or !$task->isGarbage())){ if(!$force and ($task->isRunning() or !$task->isGarbage())){
return; return;
@ -229,7 +229,7 @@ class AsyncPool{
* Removes all tasks from the pool, cancelling where possible. This will block until all tasks have been * Removes all tasks from the pool, cancelling where possible. This will block until all tasks have been
* successfully deleted. * successfully deleted.
*/ */
public function removeTasks(){ public function removeTasks() : void{
foreach($this->workers as $worker){ foreach($this->workers as $worker){
/** @var AsyncTask $task */ /** @var AsyncTask $task */
while(($task = $worker->unstack()) !== null){ while(($task = $worker->unstack()) !== null){
@ -263,7 +263,7 @@ class AsyncPool{
/** /**
* Collects garbage from running workers. * Collects garbage from running workers.
*/ */
private function collectWorkers(){ private function collectWorkers() : void{
foreach($this->workers as $worker){ foreach($this->workers as $worker){
$worker->collect(); $worker->collect();
} }
@ -274,7 +274,7 @@ class AsyncPool{
* *
* @throws \ReflectionException * @throws \ReflectionException
*/ */
public function collectTasks(){ public function collectTasks() : void{
foreach($this->tasks as $task){ foreach($this->tasks as $task){
if(!$task->isGarbage()){ if(!$task->isGarbage()){
$task->checkProgressUpdates($this->server); $task->checkProgressUpdates($this->server);