Worker
PHP Manual

Worker::stack

(PECL pthreads >= 2.0.0)

Worker::stackStacking

说明

public integer Worker::stack ( Threaded &$work )

Appends the referenced object to the stack of the referenced Worker

参数

work

Threaded object to be executed by the referenced Worker

返回值

The new length of the stack

范例

Example #1 Stacking objects for execution in Workers

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

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

$my = new Worker();
$work = new Work();
/** ... **/
var_dump($my->stack($work));
/** ... **/
?>

以上例程会输出:

int(1)


Worker
PHP Manual