public bool CanWrite(BaseEntry entry) { lock (_writeLockObject) { var entryLocker = EntryLockerAccessorFactory.GetEntryLockerAccessor(Operation.Write)(this); return(!entryLocker.CheckIsLocked(entry)); } }
public bool CanRead(BaseEntry entry) { lock (_readLockObject) { var entryLocker = EntryLockerAccessorFactory.GetEntryLockerAccessor(Operation.Read)(this); return(!entryLocker.CheckIsLocked(entry)); } }
protected LockerOperation(Locker locker, IEnumerable <BaseEntry> entries, Operation operation) { _locker = locker ?? throw new ArgumentNullException(nameof(locker)); _entries = entries ?? throw new ArgumentNullException(nameof(entries)); _operation = operation; foreach (var entry in _entries) { EntryLockerAccessorFactory.GetEntryLockerAccessor(_operation)(_locker).Lock(entry); } }
public void Dispose() { if (_isDisposed) { return; } _isDisposed = true; foreach (var entry in _entries) { EntryLockerAccessorFactory.GetEntryLockerAccessor(_operation)(_locker).Unlock(entry); } }