Crates.io | mtxgroup |
lib.rs | mtxgroup |
version | 0.1.1 |
source | src |
created_at | 2023-11-24 12:53:33.535572 |
updated_at | 2023-11-24 13:00:46.517224 |
description | mutex group locks all mutexes at the same time |
homepage | |
repository | https://github.com/Coekjan/mtxgroup |
max_upload_size | |
id | 1046994 |
size | 7,057 |
MuTeX GROUP can be used to lock all mutexes at the same time.
static MUTEX_0: Mutex<usize> = Mutex::new(0);
static MUTEX_1: Mutex<usize> = Mutex::new(1);
static MUTEX_2: Mutex<usize> = Mutex::new(2);
let mutexes = vec![&MUTEX_0, &MUTEX_1, &MUTEX_2];
let mtxgroup = MutexGroup::new(mutexes.into_iter());
let guard = mtxgroup.lock(); // Locks all mutexes at the same time
for mutex in guard.iter() {
// Do something with the mutexes
}
for mut mutex in guard.into_iter() { // `into_iter` consumes the guard
// Do something with the mutexes
}
no_std
spin
crateLicensed under MIT license