Struct tokio::runtime::task::core::Core

source ·
#[repr(C)]
pub(super) struct Core<T: Future, S> { pub(super) scheduler: S, pub(super) task_id: Id, pub(super) stage: CoreStage<T>, }
Expand description

The core of the task.

Holds the future or output, depending on the stage of execution.

Any changes to the layout of this struct must also be reflected in the const fns in raw.rs.

Fields§

§scheduler: S

Scheduler used to drive this future.

§task_id: Id

The task’s ID, used for populating JoinErrors.

§stage: CoreStage<T>

Either the future or the output.

Implementations§

source§

impl<T: Future, S: Schedule> Core<T, S>

source

pub(super) fn poll(&self, cx: Context<'_>) -> Poll<T::Output>

Polls the future.

§Safety

The caller must ensure it is safe to mutate the state field. This requires ensuring mutual exclusion between any concurrent thread that might modify the future or output field.

The mutual exclusion is implemented by Harness and the Lifecycle component of the task state.

self must also be pinned. This is handled by storing the task on the heap.

source

pub(super) fn drop_future_or_output(&self)

Drops the future.

§Safety

The caller must ensure it is safe to mutate the stage field.

source

pub(super) fn store_output(&self, output: Result<T::Output, JoinError>)

Stores the task output.

§Safety

The caller must ensure it is safe to mutate the stage field.

source

pub(super) fn take_output(&self) -> Result<T::Output, JoinError>

Takes the task output.

§Safety

The caller must ensure it is safe to mutate the stage field.

source

unsafe fn set_stage(&self, stage: Stage<T>)

Auto Trait Implementations§

§

impl<T, S> !Freeze for Core<T, S>

§

impl<T, S> !RefUnwindSafe for Core<T, S>

§

impl<T, S> Send for Core<T, S>
where S: Send, T: Send, <T as Future>::Output: Send,

§

impl<T, S> !Sync for Core<T, S>

§

impl<T, S> Unpin for Core<T, S>
where S: Unpin, T: Unpin, <T as Future>::Output: Unpin,

§

impl<T, S> !UnwindSafe for Core<T, S>

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>,

§

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>,

§

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.