Sync
Introduction
The sync extension introduces cross-platform synchonization objects into PHP. Named and unnamed Mutex, Semaphore, Event, Reader-Writer, and named Shared Memory objects provide OS-level synchronization on both POSIX (e.g. Linux) and Windows platforms.
Automatic cleanup of acquired synchronization objects takes place during extension teardown. This means that if PHP prematurely terminates a script (e.g. script execution time is exceeded), objects will not be left in an unknown state. The only exception to this is if PHP itself crashes (e.g. an internal buffer overflow).
Unnamed synchronization objects don't have a lot of use outside of a multithreaded scenario. Unnamed objects are more useful in conjunction with the pthreads PECL extension.
Note: Named objects require additional care to be used on all systems. If an object is instantiated with a specific set of parameters, it must always be instantiated with those parameters or the object will probably end up in an inconsistent state until the next reboot or a system administrator cleans up the mess.
- Installing/Configuring
- SyncMutex — The SyncMutex class
- SyncMutex::__construct — Constructs a new SyncMutex object
- SyncMutex::lock — Waits for an exclusive lock
- SyncMutex::unlock — Unlocks the mutex
- SyncSemaphore — The SyncSemaphore class
- SyncSemaphore::__construct — Constructs a new SyncSemaphore object
- SyncSemaphore::lock — Decreases the count of the semaphore or waits
- SyncSemaphore::unlock — Increases the count of the semaphore
- SyncEvent — The SyncEvent class
- SyncEvent::__construct — Constructs a new SyncEvent object
- SyncEvent::fire — Fires/sets the event
- SyncEvent::reset — Resets a manual event
- SyncEvent::wait — Waits for the event to be fired/set
- SyncReaderWriter — The SyncReaderWriter class
- SyncReaderWriter::__construct — Constructs a new SyncReaderWriter object
- SyncReaderWriter::readlock — Waits for a read lock
- SyncReaderWriter::readunlock — Releases a read lock
- SyncReaderWriter::writelock — Waits for an exclusive write lock
- SyncReaderWriter::writeunlock — Releases a write lock
- SyncSharedMemory — The SyncSharedMemory class
- SyncSharedMemory::__construct — Constructs a new SyncSharedMemory object
- SyncSharedMemory::first — Check to see if the object is the first instance system-wide of named shared memory
- SyncSharedMemory::read — Copy data from named shared memory
- SyncSharedMemory::size — Returns the size of the named shared memory
- SyncSharedMemory::write — Copy data to named shared memory