aboutsummaryrefslogtreecommitdiff
path: root/rtic-time
diff options
context:
space:
mode:
authorEmil Fresk <emil.fresk@gmail.com>2023-01-31 22:05:43 +0100
committerHenrik Tjäder <henrik@tjaders.com>2023-03-01 00:33:39 +0100
commitd0c51269608c18a105fd010f070bd9af6f443c60 (patch)
tree23b805c5b9114f3da208f0a811364635a7bfe723 /rtic-time
parent15d788b7fad0254ad3323962b8dd6753cf95796d (diff)
Cleanup common code and clippy fixes
Diffstat (limited to 'rtic-time')
-rw-r--r--rtic-time/Cargo.toml1
-rw-r--r--rtic-time/src/lib.rs27
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()() }
- }
-}