1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//! A type that can unpark specific threads.

use std::thread::Thread;

/// Can unpark a specific thread.
#[derive(Clone)]
pub struct Buzzer {
    thread: Thread,
}

impl Default for Buzzer {
    fn default() -> Self { Self { thread: std::thread::current() } }
}

impl Buzzer {
    /// Unparks the target thread.
    pub fn buzz(&self) {
        self.thread.unpark()
    }
}