#future #data-structures #mutex #data-access #non-blocking #async #lock

qutex

Synchronization mechanisms that rely on lock-free and other non-(thread)blocking techniques, such as Rust futures, to guarantee mutually exclusive or shared exclusive access to data

18 releases

0.2.6 Mar 25, 2024
0.2.4 Aug 21, 2022
0.2.3 Apr 19, 2019
0.2.2 Mar 8, 2019
0.0.5 Mar 26, 2017

#146 in Concurrency

Download history 1407/week @ 2024-07-21 1197/week @ 2024-07-28 1014/week @ 2024-08-04 1182/week @ 2024-08-11 1023/week @ 2024-08-18 1060/week @ 2024-08-25 1139/week @ 2024-09-01 1089/week @ 2024-09-08 991/week @ 2024-09-15 1117/week @ 2024-09-22 943/week @ 2024-09-29 870/week @ 2024-10-06 789/week @ 2024-10-13 707/week @ 2024-10-20 959/week @ 2024-10-27 1322/week @ 2024-11-03

3,823 downloads per month
Used in 53 crates (3 directly)

MIT license

54KB
1K SLoC

Qutex

Non-thread-blocking queue-backed data locks based on Rust futures.

Includes futures capable versions of Mutex and RwLock.

Documentation

Example

Cargo.toml:

[dependencies]
qutex = "0.2"

main.rs:

extern crate qutex;
extern crate futures;

use std::thread;
use futures::Future;
use qutex::Qutex;

fn main() {
    let thread_count = 100;
    let mut threads = Vec::with_capacity(thread_count);
    let start_val = 0;
    let qutex = Qutex::new(start_val);

    for _ in 0..thread_count {
        let future_val = qutex.clone().lock();

        let future_add = future_val.map(|mut val| {
            *val += 1;
        });

        threads.push(thread::spawn(|| {
            future_add.wait().unwrap();
        }));
    }

    for thread in threads {
        thread.join().unwrap();
    }

    let val = qutex.lock().wait().unwrap();
    assert_eq!(*val, start_val + thread_count);
    println!("Qutex final value: {}", *val);
}

Dependencies

~155–315KB