helps you monitor your threads and deal with panics
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



panic_monitor helps you monitor your threads and deal with panics.  You might
be tempted to use libstd's JoinHandles for this use-case; however, they have
two major limitations:

 * JoinHandle::join() blocks the current thread.  If you want to monitor
   multiple threads from a single "watchdog" thread, you need something like
   try_join(), and ideally you'd have an "epoll for JoinHandles" to avoid
   busy-waiting.  JoinHandle doesn't implement these, however.
 * You can't clone a JoinHandle.  If you want multiple threads to be notified
   when a particular thread panics, you can't use its JoinHandle to achieve it.

panic_monitor solves both of these issues.  PanicMonitor::wait() allows you to
specify a number of threads, and it returns as soon as one of them panics.
Threads are specified by their ThreadId (which is clonable), meaning that
mulitple threads can monitor the same thread.  Each call to
PanicMonitor::wait() can specify a different set of watched threads.

When a watched thread panics, you get a Thread struct back (which contains the
thread's name and ID).  In contrast with JoinHandle::join(), you *don't* get
the value which was passed to panic!() - this is not possible, given that this
value is not required to implement Clone.


Licensed under either of the following, at your option:

 * Apache Licence 2.0 (see LICENSE-APACHE or
 * MIT licence (see LICENSE-MIT or

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall
be dual licensed as above, without any additional terms or conditions.