PHP Class Pool, ClearSky

Mostrar archivo Open project: robske110/ClearSky Class Usage Examples

Protected Properties

Property Type Description
$class string The name of the Worker class for this Pool
$ctor array The constructor arguments to be passed by this Pool to new Workers upon construction
$last integer The numeric identifier for the last Worker used by this Pool
$size integer The maximum number of Worker threads allowed in this Pool
$workers array | Worker[] The array of Worker threads for this Pool

Public Methods

Method Description
__construct ( integer $size, string | null $class, array | null $ctor = [] ) Construct a new Pool of Workers
collect ( callable $collector ) Collect references to completed tasks
resize ( integer $size ) Resize the Pool
shutdown ( ) Shutdown all Workers in this Pool
submit ( Threaded $task ) : integer Submit the task to the next Worker in the Pool
submitTo ( integer $worker, Threaded $task ) : integer Submit the task to the specific Worker in the Pool

Method Details

__construct() public method

Construct a new Pool of Workers
public __construct ( integer $size, string | null $class, array | null $ctor = [] )
$size integer The maximum number of Workers this Pool can create
$class string | null The class for new Workers
$ctor array | null An array of arguments to be passed to new Workers

collect() public method

Allows the Pool to collect references determined to be garbage by the given collector
public collect ( callable $collector )
$collector callable

resize() public method

Resize the Pool
public resize ( integer $size )
$size integer The maximum number of Workers this Pool can create

shutdown() public method

Shutdown all Workers in this Pool
public shutdown ( )

submit() public method

Submit the task to the next Worker in the Pool
public submit ( Threaded $task ) : integer
$task Threaded The task for execution
return integer the identifier of the Worker executing the object

submitTo() public method

Submit the task to the specific Worker in the Pool
public submitTo ( integer $worker, Threaded $task ) : integer
$worker integer The worker for execution
$task Threaded The task for execution
return integer the identifier of the Worker that accepted the object

Property Details

$class protected_oe property

The name of the Worker class for this Pool
protected string $class
return string

$ctor protected_oe property

The constructor arguments to be passed by this Pool to new Workers upon construction
protected array $ctor
return array

$last protected_oe property

The numeric identifier for the last Worker used by this Pool
protected int $last
return integer

$size protected_oe property

The maximum number of Worker threads allowed in this Pool
protected int $size
return integer

$workers protected_oe property

The array of Worker threads for this Pool
protected array|Worker[] $workers
return array | Worker[]