aboutsummaryrefslogtreecommitdiff
path: root/rtic-channel
diff options
context:
space:
mode:
authorEmil Fresk <emil.fresk@gmail.com>2023-01-30 14:49:24 +0100
committerHenrik Tjäder <henrik@tjaders.com>2023-03-01 00:33:38 +0100
commit5c1cefbf4e249c38467e3f6eb4e061e5b8073d6c (patch)
treec0e8ab5b535ec4a192b9f6e83f29da8409c7016a /rtic-channel
parente65e532c2a342f77080ac6fc8e5be11aa7d82575 (diff)
Add `rtic-arbiter`
Diffstat (limited to 'rtic-channel')
-rw-r--r--rtic-channel/src/lib.rs28
1 files changed, 4 insertions, 24 deletions
diff --git a/rtic-channel/src/lib.rs b/rtic-channel/src/lib.rs
index 2b237f6..6f816b5 100644
--- a/rtic-channel/src/lib.rs
+++ b/rtic-channel/src/lib.rs
@@ -14,8 +14,11 @@ use core::{
task::{Poll, Waker},
};
use heapless::Deque;
-use rtic_common::wait_queue::{Link, WaitQueue};
use rtic_common::waker_registration::CriticalSectionWakerRegistration as WakerRegistration;
+use rtic_common::{
+ dropper::OnDrop,
+ wait_queue::{Link, WaitQueue},
+};
/// An MPSC channel for use in no-alloc systems. `N` sets the size of the queue.
///
@@ -417,29 +420,6 @@ impl<'a, T, const N: usize> Drop for Receiver<'a, T, N> {
}
}
-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()() }
- }
-}
-
#[cfg(test)]
#[macro_use]
extern crate std;