1 unstable release
0.1.0 | Jan 14, 2021 |
---|
#18 in #dropped
5KB
55 lines
Provides helpful worker threads that get joined when dropped.
Features
The crossbeam
feature will use unbounded crossbeam channels instead of std channels.
Example
#[macro_use]
extern crate drop_worker;
use drop_worker::{recv_data, try_err, DropWorker, Receiver};
fn main() {
let _worker = DropWorker::new(work);
let mut receiver = DropWorker::new(rec);
receiver.send(5);
}
fn work(recv: Receiver<()>) {
// setup
loop {
try_err!(recv);
// do work
}
}
fn rec(recv: Receiver<usize>) {
loop {
let data = recv_data!(recv);
assert_eq!(data, 5);
}
}
Dependencies
~76KB