pub fn lock() -> (Lock, LockSub)Available on crate feature
alloc only.Expand description
Acquires a Lock and its corresponding LockSub for coordinating access to a shared resource.
ยงExample
use utils_atomics::{Lock, lock};
let (lock, lock_sub) = lock();
std::thread::spawn(move || {
// Do some work with the shared resource
lock.wake();
});
// Do some work with the shared resource
lock_sub.wait();