# The Worker class

(PECL pthreads >= 2.0.0)

## Introducere

Worker Threads have a persistent context, as such should be used over Threads in most cases.

When a Worker is started, the run method will be executed, but the Thread will not leave until one of the following conditions are met:

- the Worker goes out of scope (no more references remain)

- the programmer calls shutdown

- the script dies

This means the programmer can reuse the context throughout execution; placing objects on the stack of the Worker will cause the Worker to execute the stacked objects run method.

## Sinopsisul clasei

Worker extends Thread implements Traversable , Countable , ArrayAccess {
/* Metode */
public collect ([ Callable `$collector` ] ) : int
public getStacked ( void ) : int
public isShutdown ( void ) : bool
public isWorking ( void ) : bool
public shutdown ( void ) : bool
public stack ( Threaded `&$work` ) : int
public unstack ( void ) : int
/* Metode moștenite */
public Thread::detach ( void ) : void
public Thread::getCreatorId ( void ) : int
public static Thread::getCurrentThread ( void ) : Thread
public static Thread::getCurrentThreadId ( void ) : int
public Thread::getThreadId ( void ) : int
public static Thread::globally ( void ) : mixed
public Thread::isJoined ( void ) : bool
public Thread::isStarted ( void ) : bool
public Thread::join ( void ) : bool
public Thread::kill ( void ) : void
public Thread::start ([ int `$options` ] ) : bool
}

## Cuprins

- Worker::collect — Collect references to completed tasks
- Worker::getStacked — Gets the remaining stack size
- Worker::isShutdown — State Detection
- Worker::isWorking — State Detection
- Worker::shutdown — Shutdown the worker
- Worker::stack — Stacking work
- Worker::unstack — Unstacking work