The Worker class

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
class Worker extends Thread implements Traversable, Countable, ArrayAccess {
/* Methods */
public int collect(Callable $collector = ?)
public int getStacked()
public bool isShutdown()
public bool shutdown()
public int stack(Threaded &$work)
public int unstack()
/* Inherited methods */
public int Thread::getCreatorId()
public static Thread Thread::getCurrentThread()
public static int Thread::getCurrentThreadId()
public int Thread::getThreadId()
public bool Thread::isJoined()
public bool Thread::isStarted()
public bool Thread::join()
public bool Thread::start(int $options = ?)
}
Table of Contents