timely_communication/
buzzer.rs

1//! A type that can unpark specific threads.
2
3use std::thread::Thread;
4
5/// Can unpark a specific thread.
6#[derive(Clone)]
7pub struct Buzzer {
8    thread: Thread,
9}
10
11impl Default for Buzzer {
12    fn default() -> Self { Self { thread: std::thread::current() } }
13}
14
15impl Buzzer {
16    /// Unparks the target thread.
17    pub fn buzz(&self) {
18        self.thread.unpark()
19    }
20}