crossbeam_requests 0.3.0

Crossbeam channels but with a response
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::thread;
use crossbeam_requests::channel;

fn main() {
    type RequestType = String;
    type ResponseType = String;
    let (requester, responder) = channel::<RequestType, ResponseType>();
    thread::spawn(move || {
        responder.poll_loop(|req, res_sender| res_sender.respond(req));
    });
    let msg = String::from("Hello");
    let receiver = requester.request(msg.clone()).unwrap();
    let res = receiver.collect().unwrap();
    assert_eq!(res, msg);
}