Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <equation618@gmail.com>"]
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