borrowed-thread
thread-safe way to pass borrow to thread::spawn
NEED nightly rust!
benchmark
test bench::bench_borrowed_thread ... bench: 18,902 ns/iter (+/- 690) test bench::bench_std_thread ... bench: 18,859 ns/iter (+/- 684)
examples
with &mut
use borrowed_thread;
let mut owned = "ABC".to_owned;
let borrowed_handle = spawn;
let ret = borrowed_handle.join.expect;
assert_eq!;
assert_eq!;
with &
use borrowed_thread;
let owned = "ABC".to_owned;
let borrowed_handle = spawn;
let ret = borrowed_handle.join.expect;
assert_eq!;
panic when drop without join
let mut owned = "ABC".to_owned;
let borrowed_handle = spawn;
// this will cause panic!
drop;
assert_eq!;