| 
    PocketMine-MP 5.37.1 git-cef37e7835c666594588f957a47b27d521c6a58e
    
   | 
 
 Collaboration diagram for pocketmine\scheduler\AsyncPool:Public Member Functions | |
| __construct (protected int $size, private int $workerMemoryLimit, private ThreadSafeClassLoader $classLoader, private ThreadSafeLogger $logger, private SleeperHandler $eventLoop) | |
| addWorkerStartHook (\Closure $hook) | |
| collectTasks () | |
| collectTasksFromWorker (int $worker) | |
| getRunningWorkers () | |
| getSize () | |
| getTaskQueueSizes () | |
| increaseSize (int $newSize) | |
| removeWorkerStartHook (\Closure $hook) | |
| selectWorker () | |
| shutdown () | |
| shutdownUnusedWorkers () | |
| submitTask (AsyncTask $task) | |
| submitTaskToWorker (AsyncTask $task, int $worker) | |
Manages general-purpose worker threads used for processing asynchronous tasks, and the tasks submitted to those workers.
Definition at line 47 of file AsyncPool.php.
| pocketmine\scheduler\AsyncPool::__construct | ( | protected int | $size, | 
| private int | $workerMemoryLimit, | ||
| private ThreadSafeClassLoader | $classLoader, | ||
| private ThreadSafeLogger | $logger, | ||
| private SleeperHandler | $eventLoop ) | 
Definition at line 62 of file AsyncPool.php.
| pocketmine\scheduler\AsyncPool::addWorkerStartHook | ( | \Closure | $hook | ) | 
Registers a Closure callback to be fired whenever a new worker is started by the pool. The signature should be function(int $worker) : void
This function will call the hook for every already-running worker.
@phpstan-param \Closure(int $workerId) : void $hook
Definition at line 94 of file AsyncPool.php.
| pocketmine\scheduler\AsyncPool::collectTasks | ( | ) | 
Collects finished and/or crashed tasks from the workers, firing their on-completion hooks where appropriate.
ReflectionException
Definition at line 239 of file AsyncPool.php.
| pocketmine\scheduler\AsyncPool::collectTasksFromWorker | ( | int | $worker | ) | 
Definition at line 253 of file AsyncPool.php.
| pocketmine\scheduler\AsyncPool::getRunningWorkers | ( | ) | 
Returns an array of IDs of currently running workers.
Definition at line 116 of file AsyncPool.php.
| pocketmine\scheduler\AsyncPool::getSize | ( | ) | 
Returns the maximum size of the pool. Note that there may be less active workers than this number.
Definition at line 73 of file AsyncPool.php.
| pocketmine\scheduler\AsyncPool::getTaskQueueSizes | ( | ) | 
Returns an array of worker ID => task queue size
Definition at line 299 of file AsyncPool.php.
| pocketmine\scheduler\AsyncPool::increaseSize | ( | int | $newSize | ) | 
Increases the maximum size of the pool to the specified amount. This does not immediately start new workers.
Definition at line 80 of file AsyncPool.php.
| pocketmine\scheduler\AsyncPool::removeWorkerStartHook | ( | \Closure | $hook | ) | 
Removes a previously-registered callback listening for workers being started.
@phpstan-param \Closure(int $workerId) : void $hook
Definition at line 107 of file AsyncPool.php.
| pocketmine\scheduler\AsyncPool::selectWorker | ( | ) | 
Selects a worker ID to run a task.
Definition at line 166 of file AsyncPool.php.
| pocketmine\scheduler\AsyncPool::shutdown | ( | ) | 
Cancels all pending tasks and shuts down all the workers in the pool.
Definition at line 321 of file AsyncPool.php.
| pocketmine\scheduler\AsyncPool::shutdownUnusedWorkers | ( | ) | 
Definition at line 303 of file AsyncPool.php.
| pocketmine\scheduler\AsyncPool::submitTask | ( | AsyncTask | $task | ) | 
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.
Definition at line 196 of file AsyncPool.php.
| pocketmine\scheduler\AsyncPool::submitTaskToWorker | ( | AsyncTask | $task, | 
| int | $worker ) | 
Submits an AsyncTask to an arbitrary worker.
Definition at line 146 of file AsyncPool.php.