Skip to main content

Task

Struct Task 

Source
pub struct Task { /* private fields */ }
Expand description

Minimal state used to represent a generic unit of execution used by the executors in the runtime.

Implementations§

Source§

impl Task

Source

pub fn new(priority: Priority, resume: unsafe fn(*mut Task)) -> Self

Create a new task with the given priority and resume function. The resume function is called when the thread is woken up by the scheduler internally to start executing its corresponding unit (not limited to futures).

Source

pub fn next(&self) -> Option<NonNull<Self>>

Get the link provided by the task as it can function as a linked list node.

Source

pub fn set_next(&mut self, next: Option<NonNull<Self>>)

Get the next task link having the task act as a linked list node.

Source

pub fn set_priority(&mut self, priority: Priority)

Modify the runtime priority of the task. Should only be called before the task is resumed as the scheduler could also have ownership internally.

Source

pub fn priority(&self) -> Priority

Get the assigned priority of the task.

Source

pub fn resume(&mut self)

Call the resume function provided by [new] using the given task as a parameter.

Auto Trait Implementations§

§

impl Freeze for Task

§

impl RefUnwindSafe for Task

§

impl Send for Task

§

impl Sync for Task

§

impl Unpin for Task

§

impl UnsafeUnpin for Task

§

impl UnwindSafe for Task

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.