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

use std::thread::Thread;

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

impl Buzzer {
    /// Creates a new buzzer for the current thread.
    pub fn new() -> Self {
        Self {
            thread: std::thread::current()
        }
    }
    /// Unparks the target thread.
    pub fn buzz(&self) {
        self.thread.unpark()
    }
}