yaar_lock/thread_event/
mod.rs1pub trait ThreadEvent: Sync + Default {
4 fn is_set(&self) -> bool;
6
7 fn reset(&self);
9
10 fn wait(&self);
13
14 fn set(&self);
17}
18
19#[cfg(all(feature = "os", windows))]
20mod windows;
21#[cfg(all(feature = "os", windows))]
22use windows::Event as SystemThreadEvent;
23
24#[cfg(all(feature = "os", target_os = "linux"))]
25mod linux;
26#[cfg(all(feature = "os", target_os = "linux"))]
27use linux::Event as SystemThreadEvent;
28
29#[cfg(all(feature = "os", unix, not(target_os = "linux")))]
30mod posix;
31#[cfg(all(feature = "os", unix, not(target_os = "linux")))]
32use posix::Event as SystemThreadEvent;
33
34#[cfg(feature = "os")]
35pub use self::if_os::*;
36#[cfg(feature = "os")]
37mod if_os {
38 use super::{SystemThreadEvent, ThreadEvent};
39 use core::fmt;
40
41 #[cfg_attr(feature = "nightly", doc(cfg(feature = "os")))]
43 #[derive(Default)]
44 pub struct OsThreadEvent(SystemThreadEvent);
45
46 unsafe impl Sync for OsThreadEvent {}
47 unsafe impl Send for OsThreadEvent {}
48
49 impl fmt::Debug for OsThreadEvent {
50 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
51 f.debug_struct("OsThreadEvent")
52 .field("is_set", &self.0.is_set())
53 .finish()
54 }
55 }
56
57 impl ThreadEvent for OsThreadEvent {
58 fn is_set(&self) -> bool {
59 self.0.is_set()
60 }
61
62 fn reset(&self) {
63 self.0.reset()
64 }
65
66 fn set(&self) {
67 self.0.set()
68 }
69
70 fn wait(&self) {
71 self.0.wait()
72 }
73 }
74}