RusPiRo Lock crate
API providing simple to use locks:
Spinlock
: blocking lockSemaphore
: atomic lock counter blocking or non-blockingMutex
: blocking lock to ensure mutual exclusive to its interior.RWLock
: blocking lock to provide multiple immutable and exclusive mutable access to its interior.
Usage
To use this crate simply add the dependency to your Cargo.toml
file:
[]
= "0.4.2"
Once done the definition and usage of the locks is as follows. Keep in mind to share those locking primitives accross cores or threads they should be wrapped in an Arc
.
Spinlock
use Spinlock;
Semaphore
use Semaphore;
Mutex
use Mutex;
RWLock
use RWLock;
License
Licensed under Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) or MIT (LICENSE-MIT or http://opensource.org/licenses/MIT)) at your choice.