#mutex #future #async #data-structures #mutex-lock #locking

bastion-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

2 unstable releases

0.2.4 Nov 13, 2019
0.0.0 Nov 13, 2019

#1411 in Concurrency

Download history 5/week @ 2025-01-08 13/week @ 2025-01-15 7/week @ 2025-01-22 34/week @ 2025-01-29 104/week @ 2025-02-05 16/week @ 2025-02-12 21/week @ 2025-02-19 34/week @ 2025-02-26 1/week @ 2025-03-05 17/week @ 2025-03-12 10/week @ 2025-03-19 16/week @ 2025-03-26 29/week @ 2025-04-02 8/week @ 2025-04-09

66 downloads per month

MIT license

52KB
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

~445–590KB