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
impl Task
Sourcepub fn new(priority: Priority, resume: unsafe fn(*mut Task)) -> Self
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).
Sourcepub fn next(&self) -> Option<NonNull<Self>>
pub fn next(&self) -> Option<NonNull<Self>>
Get the link provided by the task as it can function as a linked list node.
Sourcepub fn set_next(&mut self, next: Option<NonNull<Self>>)
pub fn set_next(&mut self, next: Option<NonNull<Self>>)
Get the next task link having the task act as a linked list node.
Sourcepub fn set_priority(&mut self, priority: Priority)
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.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more