Worker
Handle your jobs on the worker pool thread.
Work Interface
/**
* @param callable $work
* @return void
*
* The work is a function that will be executed when the work is run.
*/
public function add(callable $work): void;
/**
* @param int $index
* @return void
*
* Remove the work from the work list.
*/
public function remove(int $index): void;
/**
* @return void
*
* Remove all works from the work list.
*/
public function clear(): void;
/**
* @return int
*
* Get the number of works in the work list.
*/
public function count(): int;
/**
* @return bool
*
* Check if the work list is empty.
*/
public function isEmpty(): bool;
/**
* @return mixed
*
* Get the first work in the work list.
*/
public function dequeue(): mixed;
/**
* @param int $number
* @return Generator
*
* Get the work list by number.
*/
public function getArrayByNumber(int $number): Generator;
/**
* @return Generator
*
* Get all works in the work list.
*/
public function getAll(): Generator;
/**
* @return void
*
* Run all works in the work list.
*/
public function run(): void;Worker Interface
Last updated