Php/docs/class.worker

From Get docs

(PECL pthreads >= 2.0.0)

Introduction

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.


Class synopsis


Worker extends Thread implements Traversable , Countable , ArrayAccess {

/* Methods */

public collect ([ Callable $collector ] ) : int

public getStacked ( ) : int

public isShutdown ( ) : bool

public isWorking ( ) : bool

public shutdown ( ) : bool

public stack ( Threaded &$work ) : int

public unstack ( ) : int

/* Inherited methods */

public Thread::detach ( ) : void

public Thread::getCreatorId ( ) : int

public static Thread::getCurrentThread ( ) : Thread

public static Thread::getCurrentThreadId ( ) : int

public Thread::getThreadId ( ) : int

public static Thread::globally ( ) : mixed

public Thread::isJoined ( ) : bool

public Thread::isStarted ( ) : bool

public Thread::join ( ) : bool

public Thread::kill ( ) : void

public Thread::start ([ int $options ] ) : bool

}

Table of Contents