Consolidate worker data under AsyncPoolWorkerEntry

instead of having a bunch of arrays... this improves the system integrity and makes it less obnoxious to look at
This commit is contained in:
Dylan K. Taylor
2023-05-23 01:31:25 +01:00
parent ed64eac76f
commit cbda24d77e
2 changed files with 43 additions and 42 deletions

View File

@@ -23,10 +23,28 @@ declare(strict_types=1);
namespace pocketmine\scheduler;
use function time;
final class AsyncPoolWorkerEntry{
public int $lastUsed;
/**
* @var \SplQueue|AsyncTask[]
* @phpstan-var \SplQueue<AsyncTask>
*/
public \SplQueue $tasks;
public function __construct(
public readonly AsyncWorker $worker,
public readonly int $sleeperNotifierId
){}
){
$this->lastUsed = time();
$this->tasks = new \SplQueue();
}
public function submit(AsyncTask $task) : void{
$this->tasks->enqueue($task);
$this->lastUsed = time();
$this->worker->stack($task);
}
}