PHP - pool 函数


Pool 类

Pool 是可调整数量的 Worker 的容器和控制器。Pool 化可以提供 Worker 功能的更高级别抽象,包括以线程要求的方式管理引用。

类概要


Pool {
   /* 属性 */
   protected $size;
   protected $class;
   protected $workers;
   protected $ctor;
   protected $last;
   
   /* 方法 */
   public int collect([ Callable $collector ] )
   public Pool __construct( integer $size [, string $class [, array $ctor ]] )
   public void resize( integer $size )
   public void shutdown( void )
   public int submit( Threaded $task )
   public int submitTo( int $worker , Threaded $task )
}

函数列表

函数 描述
Pool::construct() 创建新的 Pool of Worker。
Pool::collect() 收集对已完成任务的引用。
Pool:: resize() 调整 Pool 的大小。
Pool::shutdown() 关闭所有 worker。
Pool::submit() 提交对象进行执行。
Pool::submitTo() 将任务提交到特定 worker 执行。