Crate minion [−] [src]
This crate provides a wrapper type for making long-running service loops cancellable.
Let's dive right in with an example. For further details see
Cancellable
.
// impl Cancellable for Service { .. } let s = Service::new(); // start the service loop on a new thread let h = s.spawn(); // get a handle that allows cancelling the service loop let exit = h.canceller(); // spin up a new thread that will handle exit signals thread::spawn(move || { // this might catch Ctrl-C from the user, wait for a particular packet, // or for any other condition that signals that the service should exit // cleanly. in this case, we just terminate after a fixed amount of time. thread::sleep(time::Duration::from_secs(1)); // tell the service loop to exit at the first opportunity exit.cancel(); }); // block until the service loop exits or errors. h.wait().unwrap();
Structs
Canceller |
A handle that allows the cancellation of a running service loop. |
Handle |
A handle to a running service loop. |
Enums
LoopState |
Indicate whether main service loop should continue accepting new work. |
Traits
Cancellable |
A service that implements |