mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-16 21:05:35 +01:00
Add rtic-arbiter
This commit is contained in:
parent
e65e532c2a
commit
5c1cefbf4e
7 changed files with 242 additions and 24 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue