spin-sync
spin-sync is a module providing synchronization primitives using spinlock. (Wikipedia Spinlock)
The main features are as follows.
- Declaring public structs
Mutex,RwLock,Once,Barrier. The interfaces are resembles those ofstd::sync. - Ensuring safety as much as
std::sync, including poisoning strategy and marker traits. - Declaring public struct
Mutex8, which behaves like a set of 8Mutexinstances except for it gives up poison strategy. It is possible to acquire 2 or more than 2 locks of 1Mutex8instance at once. - Unlike to
std::sync, the constructors of the public structs are const. For example, it is possible to declare staticMutex<T>as long as T can be build statically.
Examples
Declare static spin_sync::Mutex<u64> variable and update from multi threads.
It is impossible in case of std::sync::Mutex .
extern crate spin_sync;
use Mutex;
use thread;
// Declare static mut Mutex<u64> variable.
static COUNT: = new;
License: LGPL-3.0-or-later OR Apache-2.0 OR BSD-2-Clause