stoplight 0.3.3

Stoplight is a simple library for stoppable tasks/threads.
Documentation

Stoplight

Is a small library for stoppable threads/tasks.

use stoplight::Thread;
use std::sync::atomic::{AtomicBool, Ordering};

// spawn our task, this creates a new OS thread.
let th = Thread::spawn(|stop| {
    while !stop.load(Ordering::Relaxed) {}
    42
});

// stop signals the thread to stop.
th.stop();

// join waits for the thread to exit, then gives its return value.
assert_eq!(th.join().unwrap(), 42);