diff --git a/Cargo.toml b/Cargo.toml index 9133e80..9becd55 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "scheduler" -version = "0.1.0" +version = "0.2.0" edition = "2021" authors = ["Yuekai Jia "] description = "Various scheduler algorithms in a unified interface" @@ -10,5 +10,4 @@ repository = "https://github.com/arceos-org/scheduler" documentation = "https://arceos-org.github.io/scheduler" [dependencies] -linked_list = { git = "https://github.com/arceos-org/linked_list.git", tag = "v0.1.0" } - +linked_list_r4l = { version = "0.2.0" } diff --git a/src/fifo.rs b/src/fifo.rs index f2469e5..326d8fb 100644 --- a/src/fifo.rs +++ b/src/fifo.rs @@ -1,48 +1,14 @@ use alloc::sync::Arc; -use core::ops::Deref; -use linked_list::{Adapter, Links, List}; +use linked_list_r4l::{def_node, List}; use crate::BaseScheduler; -/// A task wrapper for the [`FifoScheduler`]. -/// -/// It add extra states to use in [`linked_list::List`]. -pub struct FifoTask { - inner: T, - links: Links, -} - -unsafe impl Adapter for FifoTask { - type EntryType = Self; - - #[inline] - fn to_links(t: &Self) -> &Links { - &t.links - } -} - -impl FifoTask { - /// Creates a new [`FifoTask`] from the inner task struct. - pub const fn new(inner: T) -> Self { - Self { - inner, - links: Links::new(), - } - } - - /// Returns a reference to the inner task struct. - pub const fn inner(&self) -> &T { - &self.inner - } -} - -impl Deref for FifoTask { - type Target = T; - #[inline] - fn deref(&self) -> &Self::Target { - &self.inner - } +def_node! { + /// A task wrapper for the [`FifoScheduler`]. + /// + /// It add extra states to use in [`linked_list::List`]. + pub struct FifoTask(T); } /// A simple FIFO (First-In-First-Out) cooperative scheduler.