Skip to main content

Crate async_priority_lock

Crate async_priority_lock 

Source
Expand description

§Async Priority Lock

Primitives for priority-sorted synchronization of resources.

Permits / lock guards are granted in order of priority, with the option to request eviction when the evict flag is enabled.

All Futures are cancel-safe.

§Feature flags:

FeatureDefaultDescription
evictEnables eviction for Semaphore and Mutex.
semaphore-totalEnables Semaphore::total_permits and Semaphore::acquire_within_total.
serdeImplement serde::Deserialize for Mutex + builtin Priority structs.
box-queueEnables queue::boxed.
arena-queueEnables queue::arena.
const-defaultImplement const_default::ConstDefault for Mutex and Semaphore. Also enables const_new fns.
mutexEnable Mutex.
semaphoreEnable Semaphore.
stdEnables use of std (disable for no_std envs. note if disabled, spin must be enabled).
allocEnables use of alloc crate. Always required for box-queue and arena-queue.
spinUse spin for internal locks (note: spin won’t be used if std flag is enabled).

Interrupt / signal safety: operations affecting the internal queues (such as locking or releasing) are not safe to call in parallel on the same thread.

i.e.: a deadlock may occur if the acquisition or dropping of a guard is interrupted, and the same thread goes on to acquire or drop a guard from the same Mutex / Semaphore.

If this is non-desireable / will cause issues, feel free to create an issue.

§Changelog

§v1.0.2
  • fix typo in feature table
  • relaxed Sized bound on Mutex T
§v1.0.1
  • fix typo in README.md example
  • fix Default impl for Semaphore
§v1.0.0
  • Added Priority and PriorityQueue traits
  • Renamed PriorityMutex -> Mutex and rewrote to use Priority and PriorityQueue traits.
  • Added Semaphore
  • Added changelog

Re-exports§

pub use priority::*;
pub use mutex::*;
pub use semaphore::*;

Modules§

mutex
Contains the Mutex type for async, priority-ordered exclusive access to a resource.
priority
Contains the Priority trait responsible for establishing entry position in PriorityQueue.
queue
Contains the PriorityQueue trait and builtin impls when features are enabled.
semaphore
Contains the Semaphore struct for async, priority-ordered acquisition of permits.