Worker
PHP Manual

Worker::stack

(PECL pthreads >= 0.36)

Worker::stackStacking

说明

final public int Worker::stack ( Stackable $work )

Appends the referenced Stackable to the stack of the referenced Worker

参数

work

An object of type Stackable to be executed by the referenced Worker

返回值

The new length of the stack

范例

Example #1 Passing Stackables to Workers for execution in the Worker Thread

<?php
class Work extends Stackable {
    
/** ... **/

    
public function run(){
        
/** ... **/
    
}
}

class 
My extends Worker {
    public function 
run(){
        
/** ... **/
    
}
}
$my = new My();
/** ... **/
var_dump($my->stack(new Work()));
/** ... **/
?>

以上例程会输出:

int(1)


Worker
PHP Manual