A non-blocking, interprocess POSIX semaphore.
Uses a POSIX message queue to store a queue of permits in a lock-free data structure. This semaphore implementation is preferred over other implementations when available, as it provides the best performance.
Not compatible with Windows.
new PosixSemaphore(int $maxLocks, int $permissions = 0600)
Creates a new semaphore with a given number of locks.
- The maximum number of locks that can be acquired from the semaphore.
- Permissions to access the semaphore.
- If the semaphore could not be created due to an internal error.
Checks if the semaphore has been freed.
Gets the access permissions of the semaphore.
PosixSemaphore::setPermissions(int $mode): void
Sets the access permissions of the semaphore.
- An octal representing the Unix permissions mode to set.
The current user must already have write access to the semaphore in order to change the semaphore's access permissions.
Removes the semaphore if it still exists. If this method is not called, the semaphore will remain in existence until the system is restarted.Next: Sync\Semaphore