Skip to content

Commit

Permalink
Use linked_list latest version
Browse files Browse the repository at this point in the history
--------

Signed-off-by: guoweikang <[email protected]>
  • Loading branch information
guoweikang committed Oct 22, 2024
1 parent c8d25d9 commit 076f3e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 43 deletions.
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "scheduler"
version = "0.1.0"
version = "0.2.0"
edition = "2021"
authors = ["Yuekai Jia <[email protected]>"]
description = "Various scheduler algorithms in a unified interface"
Expand All @@ -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" }
46 changes: 6 additions & 40 deletions src/fifo.rs
Original file line number Diff line number Diff line change
@@ -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<T> {
inner: T,
links: Links<Self>,
}

unsafe impl<T> Adapter for FifoTask<T> {
type EntryType = Self;

#[inline]
fn to_links(t: &Self) -> &Links<Self> {
&t.links
}
}

impl<T> FifoTask<T> {
/// 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<T> Deref for FifoTask<T> {
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>(T);
}

/// A simple FIFO (First-In-First-Out) cooperative scheduler.
Expand Down

0 comments on commit 076f3e1

Please sign in to comment.