diff options
Diffstat (limited to 'rtic-time')
| -rw-r--r-- | rtic-time/Cargo.toml | 1 | ||||
| -rw-r--r-- | rtic-time/src/lib.rs | 27 |
2 files changed, 3 insertions, 25 deletions
diff --git a/rtic-time/Cargo.toml b/rtic-time/Cargo.toml index ea05939..dbcf454 100644 --- a/rtic-time/Cargo.toml +++ b/rtic-time/Cargo.toml @@ -8,3 +8,4 @@ edition = "2021" [dependencies] critical-section = "1" futures-util = { version = "0.3.25", default-features = false } +rtic-common = { version = "1.0.0", path = "../rtic-common" } diff --git a/rtic-time/src/lib.rs b/rtic-time/src/lib.rs index 44fdbce..5e4457c 100644 --- a/rtic-time/src/lib.rs +++ b/rtic-time/src/lib.rs @@ -14,13 +14,13 @@ use futures_util::{ future::{select, Either}, pin_mut, }; +use linked_list::{Link, LinkedList}; pub use monotonic::Monotonic; +use rtic_common::dropper::OnDrop; mod linked_list; mod monotonic; -use linked_list::{Link, LinkedList}; - /// Holds a waker and at which time instant this waker shall be awoken. struct WaitingWaker<Mono: Monotonic> { waker: Waker, @@ -264,26 +264,3 @@ impl<Mono: Monotonic> TimerQueue<Mono> { } } } - -struct OnDrop<F: FnOnce()> { - f: core::mem::MaybeUninit<F>, -} - -impl<F: FnOnce()> OnDrop<F> { - pub fn new(f: F) -> Self { - Self { - f: core::mem::MaybeUninit::new(f), - } - } - - #[allow(unused)] - pub fn defuse(self) { - core::mem::forget(self) - } -} - -impl<F: FnOnce()> Drop for OnDrop<F> { - fn drop(&mut self) { - unsafe { self.f.as_ptr().read()() } - } -} |
