BinarySemaphore class
A BinarySemaphore is a synchronization primitive with an integer value restricted to 0 or 1, representing locked (0) or unlocked (1) states.
Constructors
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 from this semaphore.
override
-
lock(
FutureOr< void> action()) → Future<void> -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reacquire(
) → Future< void> -
Reacquires the lock as quickly as possible.
This method is not recommended for direct use.
This method is intended exclusively to ensure fair operation of reacquiring the lock in condition variable in thewait()method.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 a permit from this semaphore and waits until the
specified timeout expires.
If the semaphore is locked and timeout is zero (or not specified),falseis returned.
If the timeout expires before the semaphore is unlocked, then returnsfalse.
If permit was acquired, returnstrue.override -
tryLock(
Duration timeout, FutureOr< void> action()) → Future<bool> -
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited