PHP Class Icicle\Concurrent\Sync\PosixSemaphore

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.
Inheritance: implements Icicle\Concurrent\Sync\SemaphoreInterface, implements Serializable
Show file Open project: icicleio/concurrent

Public Methods

Method Description
__clone ( ) Clones the semaphore, creating a new semaphore with the same size and permissions.
__construct ( integer $maxLocks, integer $permissions = 384 ) Creates a new semaphore with a given number of locks.
acquire ( ) : Generator
count ( ) : integer
free ( ) Removes the semaphore if it still exists.
getPermissions ( ) : integer Gets the access permissions of the semaphore.
getSize ( ) : integer Gets the maximum number of locks held by the semaphore.
isFreed ( ) : boolean Checks if the semaphore has been freed.
serialize ( ) : string Serializes the semaphore.
setPermissions ( integer $mode ) Sets the access permissions of the semaphore.
unserialize ( string $serialized ) Unserializes a serialized semaphore.

Protected Methods

Method Description
release ( ) Releases a lock from the semaphore.

Private Methods

Method Description
init ( integer $maxLocks, integer $permissions )

Method Details

__clone() public method

Clones the semaphore, creating a new semaphore with the same size and permissions.
public __clone ( )

__construct() public method

Creates a new semaphore with a given number of locks.
public __construct ( integer $maxLocks, integer $permissions = 384 )
$maxLocks integer The maximum number of locks that can be acquired from the semaphore.
$permissions integer Permissions to access the semaphore.

acquire() public method

public acquire ( ) : Generator
return Generator

count() public method

public count ( ) : integer
return integer

free() public method

Removes the semaphore if it still exists.
public free ( )

getPermissions() public method

Gets the access permissions of the semaphore.
public getPermissions ( ) : integer
return integer A permissions mode.

getSize() public method

Gets the maximum number of locks held by the semaphore.
public getSize ( ) : integer
return integer The maximum number of locks held by the semaphore.

isFreed() public method

Checks if the semaphore has been freed.
public isFreed ( ) : boolean
return boolean True if the semaphore has been freed, otherwise false.

release() protected method

Releases a lock from the semaphore.
protected release ( )

serialize() public method

Serializes the semaphore.
public serialize ( ) : string
return string The serialized semaphore.

setPermissions() public method

The current user must have access to the semaphore in order to change the permissions.
public setPermissions ( integer $mode )
$mode integer A permissions mode to set.

unserialize() public method

Unserializes a serialized semaphore.
public unserialize ( string $serialized )
$serialized string The serialized semaphore.