PHP Class Icicle\Concurrent\Threading\Internal\Semaphore

Inheritance: extends Threaded
Afficher le fichier Open project: icicleio/concurrent Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( integer $locks ) Creates a new semaphore with a given number of locks.
acquire ( ) : Generator Uses a double locking mechanism to acquire a lock without blocking. A synchronous mutex is used to make sure that the semaphore is queried one at a time to preserve the integrity of the semaphore itself. Then a lock count is used to check if a lock is available without blocking.
count ( ) : integer Gets the number of currently available locks.

Méthodes protégées

Méthode Description
release ( ) Releases a lock from the semaphore.

Method Details

__construct() public méthode

Creates a new semaphore with a given number of locks.
public __construct ( integer $locks )
$locks integer The maximum number of locks that can be acquired from the semaphore.

acquire() public méthode

If a lock is not available, we add the request to a queue and set a timer to check again in the future.
public acquire ( ) : Generator
Résultat Generator

count() public méthode

Gets the number of currently available locks.
public count ( ) : integer
Résultat integer The number of available locks.

release() protected méthode

Releases a lock from the semaphore.
protected release ( )