tryAcquire method
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), false
is returned.
If the timeout expires before the semaphore is unlocked, then returns
false.
If permit was acquired, returns true.
Implementation
@useResult
Future<bool> tryAcquire(Duration timeout) {
if (_count > 0) {
_count--;
return _true;
}
final waiter = _queue.enqueue(timeout);
return waiter;
}