#mutex #rwlock #future #futures #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

#20 in #rwlock

Download history 13/week @ 2021-08-07 16/week @ 2021-08-14 6/week @ 2021-08-21 5/week @ 2021-08-28 16/week @ 2021-09-04 10/week @ 2021-09-11 12/week @ 2021-09-18 18/week @ 2021-09-25 39/week @ 2021-10-02 42/week @ 2021-10-09 33/week @ 2021-10-16 19/week @ 2021-10-23 25/week @ 2021-10-30 23/week @ 2021-11-06 45/week @ 2021-11-13 45/week @ 2021-11-20

86 downloads per month
Used in 2 crates (via async_progress)

Apache-2.0/MIT

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

~1MB
~14K SLoC

VG]