close method
Wait for existing locks to be released, then close this SharedMutex and prevent further locks from being taken out.
Implementation
@override
/// Wait for existing locks to be released, then close this SharedMutex
/// and prevent further locks from being taken out.
Future<void> close() async {
if (closed) {
return;
}
closed = true;
// Wait for any existing locks to complete, then prevent any further locks from being taken out.
await _acquire();
// Release the lock
_unlock();
// Close client immediately after _unlock(),
// so that we're sure no further locks are acquired.
// This also cancels any lock request in process.
client.close();
}