aboutsummaryrefslogtreecommitdiff
path: root/src/tq.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tq.rs')
-rw-r--r--src/tq.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/tq.rs b/src/tq.rs
index 9300dbfc..b2a84c85 100644
--- a/src/tq.rs
+++ b/src/tq.rs
@@ -24,18 +24,26 @@ where
N: ArrayLength<NotReady<M, T>>,
T: Copy,
{
+ /// # Safety
+ ///
+ /// Writing to memory with a transmute in order to enable
+ /// interrupts of the SysTick timer
+ ///
+ /// Enqueue a task without checking if it is full
#[inline]
pub unsafe fn enqueue_unchecked(&mut self, nr: NotReady<M, T>) {
let mut is_empty = true;
- if self
+ // Check if the top contains a non-empty element and if that element is
+ // greater than nr
+ let if_heap_max_greater_than_nr = self
.0
.peek()
.map(|head| {
is_empty = false;
nr.instant < head.instant
})
- .unwrap_or(true)
- {
+ .unwrap_or(true);
+ if if_heap_max_greater_than_nr {
if is_empty {
mem::transmute::<_, SYST>(()).enable_interrupt();
}
@@ -47,6 +55,7 @@ where
self.0.push_unchecked(nr);
}
+ /// Dequeue a task from the TimerQueue
#[inline]
pub fn dequeue(&mut self) -> Option<(T, u8)> {
unsafe {