Sync

Inhaltsverzeichnis

The SyncMutex class

Einführung

A cross-platform, native implementation of named and unnamed countable mutex objects.

A mutex is a mutual exclusion object that restricts access to a shared resource (e.g. a file) to a single instance. Countable mutexes acquire the mutex a single time and internally track the number of times the mutex is locked. The mutex is unlocked as soon as it goes out of scope or is unlocked the same number of times that it was locked.

Klassenbeschreibung

SyncMutex
class SyncMutex {
/* Methoden */
public __construct ([ string $name ] )
public bool lock ([ integer $wait = -1 ] )
public bool unlock ([ bool $all = false ] )
}

The SyncSemaphore class

Einführung

A cross-platform, native implementation of named and unnamed sempahore objects.

A semaphore restricts access to a limited resource to a limited number of instances. Semaphores differ from mutexes in that they can allow more than one instance to access a resource at one time while a mutex only allows one instance at a time.

Klassenbeschreibung

SyncSemaphore
class SyncSemaphore {
/* Methoden */
public __construct ([ string $name [, integer $initialval = 1 [, bool $autounlock = true ]]] )
public bool lock ([ integer $wait = -1 ] )
public bool unlock ([ integer &$prevcount ] )
}

The SyncEvent class

Einführung

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).

Klassenbeschreibung

SyncEvent
class SyncEvent {
/* Methoden */
public __construct ([ string $name [, bool $manual = false [, bool $prefire = false ]]] )
public bool fire ( void )
public bool reset ( void )
public bool wait ([ integer $wait = -1 ] )
}

The SyncReaderWriter class

Einführung

A cross-platform, native implementation of named and unnamed reader-writer objects.

A reader-writer object allows many readers or one writer to access a resource. This is an efficient solution for managing resources where access will primarily be read-only but exclusive write access is occasionally necessary.

Klassenbeschreibung

SyncReaderWriter
class SyncReaderWriter {
/* Methoden */
public __construct ([ string $name [, bool $autounlock = true ]] )
public bool readlock ([ integer $wait = -1 ] )
public bool readunlock ( void )
public bool writelock ([ integer $wait = -1 ] )
public bool writeunlock ( void )
}

The SyncSharedMemory class

Einführung

A cross-platform, native, consistent implementation of named shared memory objects.

Shared memory lets two separate processes communicate without the need for complex pipes or sockets. There are several integer-based shared memory implementations for PHP. Named shared memory is an alternative.

Synchronization objects (e.g. SyncMutex) are still required to protect most uses of shared memory.

Klassenbeschreibung

SyncSharedMemory
class SyncSharedMemory {
/* Methoden */
public __construct ( string $name , integer $size )
public bool first ( void )
public read ([ integer $start = 0 [, integer $length ]] )
public bool size ( void )
public write ([ string $string [, integer $start = 0 ]] )
}