#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

#105 in Concurrency

Download history 11/week @ 2019-02-01 12/week @ 2019-02-08 15/week @ 2019-02-15 37/week @ 2019-02-22 13/week @ 2019-03-01 11/week @ 2019-03-08 9/week @ 2019-03-15 27/week @ 2019-03-22 15/week @ 2019-03-29 9/week @ 2019-04-05 43/week @ 2019-04-12 23/week @ 2019-04-19 15/week @ 2019-04-26 22/week @ 2019-05-03 33/week @ 2019-05-10

96 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
~44K SLoC