Worker クラス

(PECL pthreads >= 2.0.0)

はじめに

ワーカースレッドには永続コンテキストがあり、たいていの場合はスレッドに対して使えます。

ワーカーを開始させると run メソッドを実行しますが、以下のいずれかの条件を満たすまでスレッドは終了しません。

  • Worker がスコープから外れる (どこからも参照されなくなる)

  • プログラマーが shutdown を呼ぶ

  • スクリプトが終了する

つまり、プログラマーは実行中のコンテキストを再利用できるということです。 オブジェクトを Worker のスタックに置くと、そのオブジェクトの run メソッドを Worker が実行します。

クラス概要

Worker extends Thread implements Traversable , Countable , ArrayAccess {
/* メソッド */
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
/* 継承したメソッド */
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
}

目次