php8.5
Home/ Manual/ pthreads / worker/ Worker::stack

Worker::stack

PHP function Edit on GitHub ✎

(PECL pthreads >= 2.0.0)

Stacking work

Description

Worker::stack(Threaded $work): int

Appends the new work to the stack of the referenced worker.

Parameters

work

A Threaded object to be executed by the worker.

Return Values

The new size of the stack.

Examples

Stacking a task for execution onto a worker

php
<?php
$worker = new Worker();
$work = new class extends Threaded {};

var_dump($worker->stack($work));

The above example will output:

output
int(1)

Source: reference/pthreads/worker/stack.xml · from the official PHP manual (php/doc-en)