pthreads

Table of Contents

The Thread class

Introduction

An implementation of a Thread should extend this declaration, implementing the run method. When the start method of that object is called, the run method code will be executed in separate Thread.

Class synopsis

Thread
class Thread {
/* Methods */
final public boolean chunk ( long $size , boolean $preserve )
final public long getCreatorId ( void )
final public static long getCurrentThreadId ( void )
final public long getThreadId ( void )
final public boolean isJoined ( void )
final public boolean isRunning ( void )
final public boolean isStarted ( void )
final public boolean isTerminated ( void )
final public boolean isWaiting ( void )
final public boolean join ( void )
final public boolean lock ( void )
final public boolean merge ( mixed $from [, mixed $overwrite ] )
final public boolean notify ( void )
final public boolean pop ( void )
abstract public void run ( void )
final public boolean shift ( void )
final public boolean start ([ long $options ] )
final public mixed synchronized ( Closure $block [, mixed $... ] )
final public boolean unlock ( void )
final public boolean wait ([ long $timeout ] )
}

The Worker class

Introduction

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

Class synopsis

Worker
class Worker {
/* Methods */
final public boolean chunk ( long $size , boolean $preserve )
final public long getCreatorId ( void )
final public int getStacked ( void )
final public long getThreadId ( void )
final public boolean isShutdown ( void )
final public boolean isWorking ( void )
final public boolean merge ( mixed $from [, mixed $overwrite ] )
final public boolean pop ( void )
abstract public void run ( void )
final public boolean shift ( void )
final public boolean shutdown ( void )
final public int stack ( Stackable $work )
final public boolean start ([ long $options ] )
final public int unstack ([ Stackable $work ] )
}

The Stackable class

Introduction

Stackables are tasks that are executed by Worker threads. You can synchronize with, read, and write Stackable objects before, after and during their execution.

Class synopsis

Stackable
class Stackable {
/* Methods */
final public boolean chunk ( long $size , boolean $preserve )
final public boolean isRunning ( void )
final public boolean isTerminated ( void )
final public boolean isWaiting ( void )
final public boolean lock ( void )
final public boolean merge ( mixed $from [, mixed $overwrite ] )
final public boolean notify ( void )
final public boolean pop ( void )
abstract public void run ( void )
final public boolean shift ( void )
final public mixed synchronized ( Closure $block [, mixed $... ] )
final public boolean unlock ( void )
final public boolean wait ([ string $timeout ] )
}

The Mutex class

Introduction

The static methods contained in the Mutex class provide direct access to Posix Mutex functionality.

Class synopsis

Mutex
class Mutex {
/* Methods */
final public static long create ([ boolean $lock ] )
final public static boolean destroy ( long $mutex )
final public static boolean lock ( long $mutex )
final public static boolean trylock ( long $mutex )
final public static boolean unlock ( long $mutex [, boolean $destroy ] )
}

The Cond class

Introduction

The static methods contained in the Cond class provide direct access to Posix Condition Variables.

Class synopsis

Cond
class Cond {
/* Methods */
final public static boolean broadcast ( long $condition )
final public static long create ( void )
final public static boolean destroy ( long $condition )
final public static boolean signal ( long $condition )
final public static boolean wait ( long $condition , long $mutex [, long $timeout ] )
}