From 068eea84256f5b8b6152ca0ae1ad46301fe64b12 Mon Sep 17 00:00:00 2001 From: datdenkikniet Date: Thu, 13 Apr 2023 18:49:47 +0200 Subject: rtic-common: docs --- rtic-common/src/lib.rs | 2 +- rtic-common/src/wait_queue.rs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'rtic-common') diff --git a/rtic-common/src/lib.rs b/rtic-common/src/lib.rs index 03d0306..2dd9673 100644 --- a/rtic-common/src/lib.rs +++ b/rtic-common/src/lib.rs @@ -1,4 +1,4 @@ -//! Crate +//! Utility structs that can be useful to other subcrates. #![no_std] #![deny(missing_docs)] diff --git a/rtic-common/src/wait_queue.rs b/rtic-common/src/wait_queue.rs index b1aa775..3056672 100644 --- a/rtic-common/src/wait_queue.rs +++ b/rtic-common/src/wait_queue.rs @@ -1,4 +1,4 @@ -//! ... +//! A wait queue implementation using a doubly linked list. use core::marker::PhantomPinned; use core::pin::Pin; @@ -10,7 +10,10 @@ use critical_section as cs; /// A helper definition of a wait queue. pub type WaitQueue = LinkedList; -/// A FIFO linked list for a wait queue. +/// An atomic, doubly linked, FIFO list for a wait queue. +/// +/// Atomicity is guaranteed by short [`critical_section`]s, so this list is _not_ lock free, +/// but it will not deadlock. pub struct LinkedList { head: AtomicPtr>, // UnsafeCell<*mut Link> tail: AtomicPtr>, -- cgit v1.2.3 From 68ccf0423d27041c35002f9a86bb0e764e3782b3 Mon Sep 17 00:00:00 2001 From: datdenkikniet Date: Thu, 13 Apr 2023 21:17:19 +0200 Subject: rtic-common: rename LinkedList to DoublyLinkedList --- rtic-common/src/wait_queue.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'rtic-common') diff --git a/rtic-common/src/wait_queue.rs b/rtic-common/src/wait_queue.rs index 3056672..4b1b0f3 100644 --- a/rtic-common/src/wait_queue.rs +++ b/rtic-common/src/wait_queue.rs @@ -8,18 +8,18 @@ use core::task::Waker; use critical_section as cs; /// A helper definition of a wait queue. -pub type WaitQueue = LinkedList; +pub type WaitQueue = DoublyLinkedList; /// An atomic, doubly linked, FIFO list for a wait queue. /// /// Atomicity is guaranteed by short [`critical_section`]s, so this list is _not_ lock free, /// but it will not deadlock. -pub struct LinkedList { +pub struct DoublyLinkedList { head: AtomicPtr>, // UnsafeCell<*mut Link> tail: AtomicPtr>, } -impl LinkedList { +impl DoublyLinkedList { /// Create a new linked list. pub const fn new() -> Self { Self { @@ -29,7 +29,7 @@ impl LinkedList { } } -impl LinkedList { +impl DoublyLinkedList { const R: Ordering = Ordering::Relaxed; /// Pop the first element in the queue. @@ -133,7 +133,7 @@ impl Link { } /// Remove this link from a linked list. - pub fn remove_from_list(&self, list: &LinkedList) { + pub fn remove_from_list(&self, list: &DoublyLinkedList) { cs::with(|_| { // Make sure all previous writes are visible core::sync::atomic::fence(Ordering::SeqCst); @@ -175,7 +175,7 @@ impl Link { } #[cfg(test)] -impl LinkedList { +impl DoublyLinkedList { fn print(&self) { cs::with(|_| { // Make sure all previous writes are visible @@ -235,7 +235,7 @@ mod tests { #[test] fn linked_list() { - let wq = LinkedList::::new(); + let wq = DoublyLinkedList::::new(); let i1 = Link::new(10); let i2 = Link::new(11); -- cgit v1.2.3