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:
Dylan K. Taylor 2020-10-16 21:20:49 +01:00
parent 52f734799e
commit a251960c1c

View File

@ -329,6 +329,16 @@ class AsyncPool{
$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{
$ret = 0;
$time = time();