summaryrefslogtreecommitdiff
path: root/src/util/lifo_queue.rs
diff options
context:
space:
mode:
authorChristian Cunningham <c@localhost>2022-08-23 22:18:04 -0700
committerChristian Cunningham <c@localhost>2022-08-23 22:18:04 -0700
commite746ab10da35e5d9ef957c72adf9a3ec7a7df225 (patch)
treedaf55ae2215e7934292f21de68727ba733c7b3af /src/util/lifo_queue.rs
parentec68c0209227dd371b8f1c86890575eac0277695 (diff)
Queue trait
Diffstat (limited to 'src/util/lifo_queue.rs')
-rw-r--r--src/util/lifo_queue.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/util/lifo_queue.rs b/src/util/lifo_queue.rs
index 2fa7304..07b0669 100644
--- a/src/util/lifo_queue.rs
+++ b/src/util/lifo_queue.rs
@@ -1,11 +1,11 @@
//! # Queue
//!
//! Queue structure
-use crate::sync::NullLock;
use crate::sync::interface::Mutex;
+use crate::sync::NullLock;
use crate::util::node::*;
use core::fmt;
-use core::fmt::{Debug,Formatter};
+use core::fmt::{Debug, Formatter};
/// # Initialize Queue
/// - Name: Symbol name
@@ -44,14 +44,15 @@ impl<'a, T: Sized, const COUNT: usize> LifoQueue<'a, T, COUNT> {
/// # Sharing Thread Safety for LifoQueue
unsafe impl<T, const COUNT: usize> Send for LifoQueue<'_, T, COUNT> {}
-impl<'a, T: Sized, const COUNT: usize> LifoQueue<'a, T, COUNT> {
+impl<'a, T: Sized, const COUNT: usize> crate::util::queue::Queue<'a> for LifoQueue<'a, T, COUNT> {
+ type Data = T;
/// # Initialization of Fixed-Size Pool
///
/// Establishes the header and footer of the queue
/// as the first and second elements respectively.
/// All of the internal elements point to the next
/// one and the final element points to `None`
- pub fn init(&self) {
+ fn init(&self) {
self.inner.lock(|queue| {
for idx in 1..COUNT {
if idx != COUNT - 1 {
@@ -67,7 +68,7 @@ impl<'a, T: Sized, const COUNT: usize> LifoQueue<'a, T, COUNT> {
/// # Pop
///
/// Get an item from the queue
- pub fn pop(&self) -> Option<&mut Node<'a, T>> {
+ fn pop(&self) -> Option<&mut Node<'a, T>> {
return self.inner.lock(|pool| {
if let Some(entry) = pool[0].next {
unsafe {
@@ -84,7 +85,7 @@ impl<'a, T: Sized, const COUNT: usize> LifoQueue<'a, T, COUNT> {
/// # Push
///
/// Add the item to the start of the queue.
- pub fn push(&self, freed_item: &mut Node<'a, T>) {
+ fn push(&self, freed_item: &mut Node<'a, T>) {
self.inner.lock(|pool| {
freed_item.next = pool[0].next;
pool[0].next = Some(freed_item as *mut Node<'a, T>);