Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Coekjan/mtxgroup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MuTeX GROUP

Crates.io version

Introduction

MuTeX GROUP can be used to lock all mutexes at the same time.

Example

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
}

Features

  • Compliable with no_std
    • requires spin crate

License

Licensed under MIT license

About

Mutex Group for Rust Language, can be used to lock all the Mutexes at the same time!

Resources

License

Stars

Watchers

Forks

Languages