mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 20:28:31 +00:00
AsyncPool: expose workerUsage to the API
this allows plugins (and maybe later on the core) to detect async worker overload and warn the user about potential performance issues. I planned to implement such detection in the core directly, but it turned out to be a bit more complex than I anticipated. At the least, this API might be useful to someone else.
This commit is contained in:
parent
52f734799e
commit
a251960c1c
@ -329,6 +329,16 @@ class AsyncPool{
|
|||||||
$this->collectWorkers();
|
$this->collectWorkers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of worker ID => task queue size
|
||||||
|
*
|
||||||
|
* @return int[]
|
||||||
|
* @phpstan-return array<int, int>
|
||||||
|
*/
|
||||||
|
public function getTaskQueueSizes() : array{
|
||||||
|
return $this->workerUsage;
|
||||||
|
}
|
||||||
|
|
||||||
public function shutdownUnusedWorkers() : int{
|
public function shutdownUnusedWorkers() : int{
|
||||||
$ret = 0;
|
$ret = 0;
|
||||||
$time = time();
|
$time = time();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user