go-spawn
go-spawn
is a library that provides macros to spawn and join threads with minimal boilerplate.
Threads can be spawned with either go!
or go_ref!
and can be joined with either join!
or
join_all!
.
Installation
go-spawn
is published on https://crates.io
. To use in your Rust project, add the latest version
of go-spawn
to your Cargo.toml
file:
[]
= "0.1.0"
Examples.
use ;
use ;
let counter = new;
let counter_cloned = counter.clone;
// Spawn a thread that captures values by move.
go!
// Join the most recent thread spawned by `go_spawn` that has not yet been joined.
assert!;
assert_eq!;
use ;
use ;
static COUNTER: AtomicI64 = new;
for _ in 0..10
// Join all not-yet-joined threads spawned by `go_spawn`.
join_all!;
assert_eq!;
Documentation
Documentation can be found at https://docs.rs/go-spawn
.