pht

目次

The Thread class

はじめに

The pht\Thread class abstracts away a native thread. It has an internal task queue, where the methods pht\Thread::addClassTask, pht\Thread::addFunctionTask, and pht\Thread::addFileTask push new tasks onto this queue. Invoking the pht\Thread::start method will cause the new thread to be spawned, where it will then begin working through the task queue. A thread may be reused for any number of tasks.

クラス概要

pht\Thread
class pht\Thread {
/* メソッド */
public void addClassTask ( string $className , mixed $ctorArgs )
public void addFileTask ( string $fileName , mixed $globals )
public void addFunctionTask ( callable $func , mixed $funcArgs )
public void join ( void )
public void start ( void )
public int taskCount ( void )
}

The Runnable interface

はじめに

The pht\Runnable interface enforces the implementation of a run() method on classes that should be threaded. This method acts as the entry point of the threaded class.

インターフェイス概要

pht\Runnable
class pht\Runnable {
/* メソッド */
public void run ( void )
}

The HashTable class

はじめに

The pht\HashTable class is one of the Inter-Thread Communication (ITC) data structures exposed by pht. It can be safely passed around between threads, and manipulated by multiple threads using the mutex locks that have been packed in with the data structure. It is reference-counted across threads, and so it does not need to be explicitly destroyed.

The pht\HashTable class enables for array access upon its objects (along with the isset and unset functions). The ArrayAccess interface is not explicitly implemented, however, because it is only needed for such abilities by userland classes.

クラス概要

pht\HashTable
class pht\HashTable implements pht\Threaded {
/* メソッド */
public void lock ( void )
public int size ( void )
public void unlock ( void )
}

The Vector class

はじめに

The pht\Vector class is one of the Inter-Thread Communication (ITC) data structures exposed by pht. It can be safely passed around between threads, and manipulated by multiple threads using the mutex locks that have been packed in with the data structure. It is reference-counted across threads, and so is does not need to be explicitly destroyed.

The pht\Vector class enables for array access upon its objects (along with the isset and unset functions). The ArrayAccess interface is not explicitly implemented, however, because it is only needed for such abilities by userland classes.

クラス概要

pht\Vector
class pht\Vector implements pht\Threaded {
/* メソッド */
public Vector __construct ([ int $size = 0 [, mixed $value = 0 ]] )
public void deleteAt ( int $offset )
public void insertAt ( mixed $value , int $offset )
public void lock ( void )
public mixed pop ( void )
public void push ( mixed $value )
public void resize ( int $size [, mixed $value = 0 ] )
public mixed shift ( void )
public int size ( void )
public void unlock ( void )
public void unshift ( mixed $value )
public void updateAt ( mixed $value , int $offset )
}

The Queue class

はじめに

The pht\Queue class is one of the Inter-Thread Communication (ITC) data structures exposed by pht. It can be safely passed around between threads, and manipulated by multiple threads using the mutex locks that have been packed in with the data structure. It is reference-counted across threads, and so it does not need to be explicitly destroyed.

クラス概要

pht\Queue
class pht\Queue implements pht\Threaded {
/* メソッド */
public mixed front ( void )
public void lock ( void )
public mixed pop ( void )
public void push ( mixed $value )
public int size ( void )
public void unlock ( void )
}

The AtomicInteger class

はじめに

The pht\AtomicInteger class is currently the only supported atomic value. It allows for an integer to be safely passed around between, and manipulated, by multiple threads. The methods exposed by this class do not need mutex locking, since they will acquire the internal mutex lock implicitly. pht\AtomicInteger::lock and pht\AtomicInteger::unlock are still exposed, however, for when multiple operations involving the same pht\AtomicInteger object need to be grouped together.

The mutex locks of the atomic values are reentrant safe.

クラス概要

pht\AtomicInteger
class pht\AtomicInteger implements pht\Threaded {
/* メソッド */
public AtomicInteger __construct ([ int $value = 0 ] )
public void dec ( void )
public int get ( void )
public void inc ( void )
public void lock ( void )
public void set ( int $value )
public void unlock ( void )
}

The Threaded interface

はじめに

The pht\Threaded interface is an internal interface used by the Inter-Thread Communication (ITC) data structures (pht\HashTable, pht\Queue, and pht\Vector). It allows those data structures to be threaded and ensures that the mutex locking API ( pht\Threaded::lock and pht\Threaded::unlock) is implemented by each of the ITC data structures. It is not implementable by userland classes (since standalone mutex locks are not exposed).

インターフェイス概要

pht\Threaded
class pht\Threaded {
/* メソッド */
public void lock ( void )
public void unlock ( void )
}