class SyncEvent (View source)

SyncEvent

A cross-platform, native implementation of named and unnamed event objects. Both automatic and manual event objects are supported. An event object waits, without polling, for the object to be fired/set. One instance waits on the event object while another instance fires/sets the event. Event objects are useful wherever a long-running process would otherwise poll a resource (e.g. checking to see if uploaded data needs to be processed).

Methods

__construct(string $name, bool $manual = false, bool $prefire = false)

SyncEvent constructor.

bool
fire()

Fires/sets the event

bool
reset()

Resets a manual event

bool
wait(int $wait = -1)

Waits for the event to be fired/set

Details

__construct(string $name, bool $manual = false, bool $prefire = false)

Since: 1.0.0

SyncEvent constructor.

Parameters

string $name

The name of the event if this is a named event object. Note: If the name already exists, it must be able to be opened by the current user that the process is running as or an exception will be thrown with a meaningless error message.

bool $manual

[optional] Specifies whether or not the event object must be reset manually. Note: Manual reset event objects allow all waiting processes through until the object is reset.

bool $prefire

[optional] Specifies whether or not to prefire (signal) the event object. Note: Only has impact if the calling process/thread is the first to create the object.

Exceptions

Exception

bool fire()

Fires/sets the event

Fires/sets a SyncEvent object. Lets multiple threads through that are waiting if the event object was created with a manual value of TRUE.

Return Value

bool

TRUE if the event was fired, FALSE otherwise.

See also

SyncEvent::wait

bool reset()

Resets a manual event

Resets a SyncEvent object that has been fired/set. Only valid for manual event objects.

Return Value

bool

TRUE if the object was successfully reset, FALSE otherwise.

bool wait(int $wait = -1)

Waits for the event to be fired/set

Waits for the SyncEvent object to be fired.

Parameters

int $wait

The number of milliseconds to wait for the event to be fired. A value of -1 is infinite.

Return Value

bool

TRUE if the event was fired, FALSE otherwise.

See also

SyncEvent::fire