diff options
author | Guanhao Yin <sopium@mysterious.site> | 2017-03-25 19:22:27 +0800 |
---|---|---|
committer | Guanhao Yin <sopium@mysterious.site> | 2017-03-25 21:51:17 +0800 |
commit | 400c8ec614ae9c1266752df04630e23716c37d34 (patch) | |
tree | d070fdf1df94c9e5685a6cab29758781e2f72076 /src | |
parent | Use a global timer (diff) | |
download | wireguard-rs-400c8ec614ae9c1266752df04630e23716c37d34.tar.xz wireguard-rs-400c8ec614ae9c1266752df04630e23716c37d34.zip |
Add TimerHandle::dummy(), don't put dummy timers into the wheel
Diffstat (limited to 'src')
-rw-r--r-- | src/protocol/timer.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/protocol/timer.rs b/src/protocol/timer.rs index 96490d1..5b8cf13 100644 --- a/src/protocol/timer.rs +++ b/src/protocol/timer.rs @@ -133,6 +133,20 @@ impl TimerController { } impl TimerHandle { + /// Create a dummy handle, that does not point to an actual timer. + /// + /// Dummy handles MUST NOT be adjusted! + pub fn dummy() -> Self { + TimerHandle { + pos: AtomicUsize::new(0), + timer: ArcTimer(Arc::new(Timer { + activated: AtomicBool::new(false), + rounds: AtomicUsize::new(0), + action: Box::new(|| {}), + })), + } + } + pub fn activate(&self) { self.timer.activated.store(true, Ordering::Relaxed); } |