PT
apps/winzik / src / Work / JobPool.php · commit 6576d6f
<?phpnamespace App\Work;/** * Where the IDE sends its CPU work (the first indexing of a project and its libraries): helper processes (WorkerPool, every * desktop) or threads of the same process (ThreadJobs, the IDE on PHP 8.6 ZTS + TrueAsync). Jobs are Worker's: plain values in, * plain values out. Never blocks; a rejected job is done by its caller (the single-thread path is always kept). */interface JobPool{    /** A job: its answer (a plain value) or a WorkerError. Never blocks; a closed pool rejects at once. */    public function submit(string $type, array $payload = [], float $timeout = 60.0): Deferred;    /** Whether it can take jobs now (the first call starts it). */    public function ready(): bool;    /** Whether it can take jobs at all (false once closed). */    public function available(): bool;    /** Jobs not answered yet. */    public function pending(): int;    /** How many more jobs it is worth giving now. */    public function room(): int;    /** Settles what came back, for at most $budget seconds (on the IDE's thread, between frames). */    public function poll(float $budget = 0.004): void;    /** Stops it; the jobs not answered are rejected. */    public function close(string $why = 'closed'): void;    /** Nothing to do: what it holds may be let go (it starts again with the next job). */    public function idle(): void;    /** Whether it still needs polling. */    public function busy(): bool;    /** What the Logs / the performance command show. @return array<string, mixed> */    public function status(): array;}