spinlock-rs
This Rust library implements a simple spinlock.
Build
Just run cargo build
.
Usage
When calling lock
on a Spinlock
you will get a reference to the data. When this reference is dropped, the lock will be unlocked.
extern crate spinlock;
use Spinlock;
To share the lock, an Arc<Spinlock<T>>
may be used.
Remarks
The behaviour of this lock is similar to that of std::sync::Mutex
. It differs on the following:
- The lock will not be poisoned in case of failure;
- The lock can also be used from a plain thread (such as a bare
pthread
).