diff options
Diffstat (limited to 'vendor/flume/src/signal.rs')
-rw-r--r-- | vendor/flume/src/signal.rs | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/vendor/flume/src/signal.rs b/vendor/flume/src/signal.rs deleted file mode 100644 index 89395a3..0000000 --- a/vendor/flume/src/signal.rs +++ /dev/null @@ -1,33 +0,0 @@ -use std::{thread::{self, Thread}, time::Duration, any::Any}; - -pub trait Signal: Send + Sync + 'static { - /// Fire the signal, returning whether it is a stream signal. This is because streams do not - /// acquire a message when woken, so signals must be fired until one that does acquire a message - /// is fired, otherwise a wakeup could be missed, leading to a lost message until one is eagerly - /// grabbed by a receiver. - fn fire(&self) -> bool; - fn as_any(&self) -> &(dyn Any + 'static); - fn as_ptr(&self) -> *const (); -} - -pub struct SyncSignal(Thread); - -impl Default for SyncSignal { - fn default() -> Self { - Self(thread::current()) - } -} - -impl Signal for SyncSignal { - fn fire(&self) -> bool { - self.0.unpark(); - false - } - fn as_any(&self) -> &(dyn Any + 'static) { self } - fn as_ptr(&self) -> *const () { self as *const _ as *const () } -} - -impl SyncSignal { - pub fn wait(&self) { thread::park(); } - pub fn wait_timeout(&self, dur: Duration) { thread::park_timeout(dur); } -} |