stoplight

Crates.iostoplight
lib.rsstoplight
version0.3.3
sourcesrc
created_at2019-10-23 01:50:14.606532
updated_at2019-10-30 15:45:31.694852
descriptionStoplight is a simple library for stoppable tasks/threads.
homepage
repositoryhttps://github.com/UlisseMini/stoplight
max_upload_size
id174766
size5,389
Ulisse mini (UlisseMini)

documentation

README

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);
Commit count: 3

cargo fmt