#coroutine #multi-thread

bin+lib may_waiter

Simple coroutine communication blocker

3 releases

0.1.2 Apr 15, 2019
0.1.1 Jan 31, 2019
0.1.0 May 10, 2018

#97 in Concurrency

Download history 18/week @ 2018-12-31 47/week @ 2019-01-07 30/week @ 2019-01-14 33/week @ 2019-01-21 33/week @ 2019-01-28 3/week @ 2019-02-04 13/week @ 2019-02-11 21/week @ 2019-02-18 31/week @ 2019-02-25 14/week @ 2019-03-04 7/week @ 2019-03-11 13/week @ 2019-03-18 27/week @ 2019-03-25 14/week @ 2019-04-01 8/week @ 2019-04-08

82 downloads per month

MIT/Apache

9KB
174 lines

Build Status Current Crates.io Version Document

coroutine waiter library

This library provide a map associated blocking primitive that waiting for a response produced by another coroutine

Usage

  • the map associated interface is through WaiterMap
fn test_waiter_map() {
    let req_map = Arc::new(WaiterMap::<usize, usize>::new());
    let rmap = req_map.clone();

    let key = 1234;

    // one coroutine wait data send from another coroutine
    // prepare the waiter first
    let waiter = req_map.new_waiter(key);

    // trigger the rsp in another coroutine
    go!(move || rmap.set_rsp(&key, 100).ok());

    // this will block until the rsp was set
    let result = waiter.wait_rsp(None).unwrap();
    assert_eq!(result, 100);
}

Dependencies

~2.5MB
~42K SLoC