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 Buzzer {
12 /// Creates a new buzzer for the current thread.
13 pub fn new() -> Self {
14 Self {
15 thread: std::thread::current()
16 }
17 }
18 /// Unparks the target thread.
19 pub fn buzz(&self) {
20 self.thread.unpark()
21 }
22}