CountingSemaphore class

A CountingSemaphore is a synchronization primitive that maintains a counter that represents the number of available permits.

Acquire:
If the counter is 0, the caller blocks (sleeps) until the count becomes greater than 0.
Otherwise, the counter is decremented, and the caller acquires a permit.

Release:
If any caller were blocked, one is woken up to acquire permit.
Otherwise, the counter is incremented.

Constructors

CountingSemaphore(int initialCount, int maxCount)
Creates an instance of CountingSemaphore.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

acquire() Future<void>
Acquires a permit.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
release() Future<void>
Releases a permit.
toString() String
A string representation of this object.
inherited
tryAcquire(Duration timeout) Future<bool>
Tries to acquire the permit and returns true if the permit was acquired before the timeout expires, otherwise the acquisition attempt is canceled and false is returned.

Operators

operator ==(Object other) bool
The equality operator.
inherited