Crates.io | thread_spawn |
lib.rs | thread_spawn |
version | 0.4.0 |
source | src |
created_at | 2018-05-15 19:47:04.524801 |
updated_at | 2018-06-13 18:49:59.207581 |
description | A plugin for authoring functions that spawn threads. |
homepage | |
repository | https://github.com/tcr/thread_spawn |
max_upload_size | |
id | 65594 |
size | 4,617 |
Write Rust functions that spawn threads and implicitly return JoinHandles.
#![feature(plugin, proc_macro)]
extern crate thread_spawn;
use thread_spawn::thread_spawn;
#[thread_spawn]
fn foo(a: u8, b: u8, (c, _): (u8, u8)) -> bool {
assert!(a + b + c == 5);
5 - c == b
}
fn main() {
let mut x = 0;
let mut y = 1;
let res = foo(x, y, (4, 0)).join(); // explicit join call
match res {
Ok(res) => println!("result: {:?}", res),
Err(err) => panic!("Thread panicked: {:?}", err),
}
}
Upsides:
async
keyword, conceptually.MIT or Apache-2.0, at your option.