#future #rwlock #mutex #async

future-parking_lot

An "as simple as possible" Future implementation for parking_lot

7 releases

0.3.3 Nov 7, 2019
0.3.2-alpha.2 Aug 28, 2019
0.2.0-alpha.2 Aug 22, 2019
0.1.1 Jun 28, 2019

#48 in #rwlock

Download history 26/week @ 2024-11-13 38/week @ 2024-11-20 43/week @ 2024-11-27 46/week @ 2024-12-04 63/week @ 2024-12-11 23/week @ 2024-12-18 2/week @ 2024-12-25 23/week @ 2025-01-08 25/week @ 2025-01-15 14/week @ 2025-01-22 17/week @ 2025-01-29 21/week @ 2025-02-05 67/week @ 2025-02-12 44/week @ 2025-02-19 10/week @ 2025-02-26

147 downloads per month
Used in 2 crates

Apache-2.0/MIT

29KB
669 lines

future-parking_lot

This is an "as simple as possible" Future implementation for parking_lot. Thanks to async/await feature, now it works directly on Mutex<T> and RwLock<T>.

Example:

use std::sync::Arc;

use parking_lot::RwLock;

use future_parking_lot::rwlock::{FutureReadable, FutureWriteable};

use lazy_static::lazy_static;

lazy_static! {
    static ref LOCK: Arc<RwLock<Vec<String>>> = Arc::new(RwLock::new(Vec::new()));
}

#[tokio::main]
async fn main() -> Result<(), ()> {
    {
        let mut v = LOCK.future_write().await;
        v.push(String::from("It works!"));
    }

    let v = LOCK.future_read().await;
    assert!(v.len() == 1 && v[0] == "It works!");

    Ok(())
}

lib.rs:

future-parking_lot

A simple Future implementation for parking_lot

Dependencies

~0.8–1.1MB
~17K SLoC