diff --git a/Cargo.toml b/Cargo.toml index 9133e80..b4edd49 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,5 +10,5 @@ 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 = { git = "https://github.com/arceos-org/linked_list.git", branch = "guoweikang/linked_list" } diff --git a/src/fifo.rs b/src/fifo.rs index f2469e5..4fc5e3a 100644 --- a/src/fifo.rs +++ b/src/fifo.rs @@ -1,49 +1,10 @@ use alloc::sync::Arc; -use core::ops::Deref; -use linked_list::{Adapter, Links, List}; +use linked_list::{def_generic_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_generic_node!(FifoTask); /// A simple FIFO (First-In-First-Out) cooperative scheduler. ///