Crate lilos_rwlock

Crate lilos_rwlock 

Source
Expand description

A read-write lock for use with lilos.

There’s a small family of related types in this here crate:

  • RwLock<T> contains some data of type T and allows either multiple shared references, or one exclusive reference, but not both simultaneously.
  • SharedGuard<T> represents a shared reference to the data guarded by a RwLock and allows access to it (via Deref).
  • ActionPermit<T> represents an exclusive reference to the data guarded by a RwLock, but once you start doing something that can modify the data, you can’t await, to ensure that cancellation won’t corrupt the guarded data.
  • ExclusiveGuard<T> allows arbitrary exclusive access, even across await points, but you have to promise the library that the data is inherently cancel-safe (by using the lilos::util::CancelSafe marker type).

See the docs on RwLock for more details.

Macros§

create_rwlock
Convenience macro for creating an RwLock.

Structs§

ActionPermit
Permit returned by RwLock::lock_exclusive or RwLock::try_lock_exclusive that indicates that the holder has exclusive access to the lock, and that permits non-async alterations to the guarded data.
ExclusiveGuard
A resource object that grants read/write access to the data guarded by an RwLock.
InUse
Error produced by RwLock::try_lock_shared and related non-blocking locking operations.
RwLock
A lock that guards data of type T and allows, at any one time, shared access by many readers, or exclusive access by one writer, but not both.
SharedGuard
Resource object that grants shared access to guarded data of type T.