Crate minion[][src]

Expand description

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.

    // tell the service loop to exit at the first opportunity

// block until the service loop exits or errors.


A handle that allows the cancellation of a running service loop.

A handle to a running service loop.


Indicate whether main service loop should continue accepting new work.


A service that implements Cancellable can be told to stop accepting new work at any time, and will return at the first following opportunity.