PHP - Pool::submitTo() Function



Pool::submitTo() function can submit a task to a specific worker for execution.

Syntax

public int Pool::submitTo( int $worker , Threaded $task )

Pool::submitTo() function can submit a task to a specified worker in the pool. The workers are indexed from 0, and can only exist if a pool has needed to create them.

Pool::submitTo() function can return an identifier of a worker that accepted the task.

Example

<?php class Task extends Threaded { public function run() { var_dump(Thread::getCurrentThreadID()); } } $pool = new Pool(2); $pool->submit(new Task()); for($i = 0; $i < 5; ++$i) { $pool->submitTo(0, new Task()); } $pool->submitTo(1, new Task()); $pool->shutdown(); ?>
php_function_reference.htm
Advertisements