tryLock method
Implementation
@useResult
Future<bool> tryLock(
Duration timeout, FutureOr<void> Function() action) async {
final isSuccess = await tryAcquire(timeout);
if (isSuccess) {
try {
await action();
} finally {
await release();
}
}
return isSuccess;
}