tryAcquire method
Try to acquire without blocking. Returns true on success, false if another process currently holds it.
Implementation
Future<bool> tryAcquire({bool exclusive = true}) async {
final canon = _canonical(lockPath);
if (_processHeld.contains(canon)) return false;
final raf = await _openLockFile();
try {
await raf.lock(exclusive ? FileLock.exclusive : FileLock.shared);
_raf = raf;
_processHeld.add(canon);
return true;
} catch (_) {
try {
await raf.close();
} catch (_) {/* ignore */}
return false;
}
}