no_std synchonization primitives using spinlock.
spin-rs
instead.
In software engineering, a spinlock is a lock which causes a thread trying to acquire it to simply wait in a loop ("spin") while repeatedly checking if the lock is available.
From wikipedia.
- Mutex
- RwLock
- Handle panicking
use std::thread;
use std::sync::Arc;
use spinlock::Mutex;
let count = Arc::new(Mutex::new(0));
let count1 = Arc::clone(&count);
let _ = thread::spawn(move || {
*count1.lock() += 1;
}).join();
assert_eq!(*count.lock(), 1);
- Correctly implementing a spinlock in C++
- The black art of concurrency
- Nomicon chapter on concurrency
This project is licensed under MIT License.