BinarySemaphore class

A BinarySemaphore is a synchronization primitive with an integer value restricted to 0 or 1, representing locked (0) or unlocked (1) states.

Inheritance

Constructors

BinarySemaphore()

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.
override
lock(FutureOr<void> action()) Future<void>
Acquires the lock, then executes the callback function action, and then releases the lock.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reacquire() Future<void>
Reacquires a permit.
override
release() Future<void>
Releases a permit.
override
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.
override
tryLock(Duration timeout, FutureOr<void> action()) Future<bool>
Tries to acquire the lock to execute an action and returns true if the lock was acquired before the timeout expires, otherwise the acquisition attempt is canceled and false is returned.
inherited

Operators

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