RateLimitingSemaphore
in package
implements
Semaphore
uses
ForbidCloning, ForbidSerialization
FinalYes
When a locked is released from this semaphore, it does not become available to be acquired again until the given lock-period has elapsed. This is useful when a number of operations or requests must be limited to a particular quantity within a certain time period.
Table of Contents
Interfaces
- Semaphore
- A counting semaphore.
Properties
- $lockPeriod : float
- $semaphore : Semaphore
- $timers : SplQueue<string|int, string>
- $waitingCount : int
Methods
- __construct() : mixed
- __serialize() : never
- __unserialize() : never
- acquire() : Lock
- Acquires a lock on the semaphore. Semaphores may have one or more locks.
- __clone() : mixed
- release() : void
Properties
$lockPeriod read-only
private
float
$lockPeriod
$semaphore read-only
private
Semaphore
$semaphore
$timers read-only
private
SplQueue<string|int, string>
$timers
List of event-loop delay callback IDs.
$waitingCount
private
int
$waitingCount
= 0
Methods
__construct()
public
__construct(Semaphore $semaphore, float $lockPeriod) : mixed
Parameters
- $semaphore : Semaphore
- $lockPeriod : float
-
Time after which a lock is released from the semaphore after being initially released by the consumer.
__serialize()
public
final __serialize() : never
Return values
never__unserialize()
public
final __unserialize(array<string|int, mixed> $data) : never
Parameters
- $data : array<string|int, mixed>
Return values
neveracquire()
Acquires a lock on the semaphore. Semaphores may have one or more locks.
public
acquire() : Lock
Return values
Lock —Returns with a lock object once a lock is obtained. May fail with a SyncException if an error occurs when attempting to obtain the lock (e.g. a shared memory segment closed).
__clone()
protected
final __clone() : mixed
release()
private
release(Lock $lock) : void
Parameters
- $lock : Lock