maitake::task

Struct Builder

Source
pub struct Builder<'a, S> { /* private fields */ }
Expand description

Builds a new Task prior to spawning it.

Implementations§

Source§

impl<'a, S: Schedule + 'static> Builder<'a, S>

Source

pub fn name(self, name: &'a str) -> Self

Adds a name to the tasks produced by this builder.

This will set the task.name tracing field of spans generated for this task, if the “tracing-01” or “tracing-02” feature flags are enabled.

By default, tasks are unnamed.

Source

pub fn kind(self, kind: &'static str) -> Self

Adds a static string which describes the type of the configured task.

Generally, this is set by the runtime, rather than by user code — kinds should describe general categories of task, such as “local” or “blocking”, rather than identifying specific tasks in an application. The name field should be used instead for naming specific tasks within an application.

This will set the task.kind tracing field of spans generated for this task, if the “tracing-01” or “tracing-02” feature flags are enabled.

By default, tasks will have the kind “task”.

Source

pub fn location(self, location: Location<'a>) -> Self

Overrides the task’s source code location.

By default, tasks will be recorded as having the location from which they are spawned. This may be overriden by the runtime if needed.

Source

pub fn spawn_allocated<STO, F>( &self, task: STO::StoredTask, ) -> JoinHandle<F::Output>
where F: Future + Send + 'static, F::Output: Send + 'static, STO: Storage<S, F>,

Spawns a new task in a custom allocation, with this builder’s configured settings.

Note that the StoredTask must be bound to the same scheduler instance as this task’s scheduler!

This method returns a JoinHandle that can be used to await the task’s output. Dropping the JoinHandle detaches the spawned task, allowing it to run in the background without awaiting its output.

Source§

impl Builder<'_, &'static LocalStaticScheduler>

Source

pub fn spawn_local_allocated<STO, F>( &self, task: STO::StoredTask, ) -> JoinHandle<F::Output>
where F: Future + 'static, F::Output: 'static, STO: Storage<&'static LocalStaticScheduler, F>,

Spawns a new !Send task in a custom allocation, with this builder’s configured settings.

This method is capable of spawning futures which do not implement Send. Therefore, it is only available when this Builder was returned by a LocalStaticScheduler

Note that the StoredTask must be bound to the same scheduler instance as this task’s scheduler!

This method returns a JoinHandle that can be used to await the task’s output. Dropping the JoinHandle detaches the spawned task, allowing it to run in the background without awaiting its output.

Source§

impl<S: Schedule + 'static> Builder<'_, S>

Source

pub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>
where F: Future + Send + 'static, F::Output: Send + 'static,

Spawns a new task with this builder’s configured settings.

This method returns a JoinHandle that can be used to await the task’s output. Dropping the JoinHandle detaches the spawned task, allowing it to run in the background without awaiting its output.

Source§

impl Builder<'_, &'static LocalStaticScheduler>

Source

pub fn spawn_local<F>(&self, future: F) -> JoinHandle<F::Output>
where F: Future + 'static, F::Output: 'static,

Spawns a new !Send task with this builder’s configured settings.

This method is capable of spawning futures which do not implement Send. Therefore, it is only available when this Builder was returned by a LocalStaticScheduler

This method returns a JoinHandle that can be used to await the task’s output. Dropping the JoinHandle detaches the spawned task, allowing it to run in the background without awaiting its output.

Source§

impl Builder<'_, LocalScheduler>

Source

pub fn spawn_local<F>(&self, future: F) -> JoinHandle<F::Output>
where F: Future + 'static, F::Output: 'static,

Spawns a new !Send task with this builder’s configured settings.

This method is capable of spawning futures which do not implement Send. Therefore, it is only available when this Builder was returned by a LocalScheduler

This method returns a JoinHandle that can be used to await the task’s output. Dropping the JoinHandle detaches the spawned task, allowing it to run in the background without awaiting its output.

Source

pub fn spawn_local_allocated<STO, F>( &self, task: STO::StoredTask, ) -> JoinHandle<F::Output>
where F: Future + 'static, F::Output: 'static, STO: Storage<LocalScheduler, F>,

Spawns a new !Send task in a custom allocation, with this builder’s configured settings.

This method is capable of spawning futures which do not implement Send. Therefore, it is only available when this Builder was returned by a LocalStaticScheduler

Note that the StoredTask must be bound to the same scheduler instance as this task’s scheduler!

This method returns a JoinHandle that can be used to await the task’s output. Dropping the JoinHandle detaches the spawned task, allowing it to run in the background without awaiting its output.

Trait Implementations§

Source§

impl<'a, S: Clone> Clone for Builder<'a, S>

Source§

fn clone(&self) -> Builder<'a, S>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, S: Debug> Debug for Builder<'a, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, S> Freeze for Builder<'a, S>
where S: Freeze,

§

impl<'a, S> RefUnwindSafe for Builder<'a, S>
where S: RefUnwindSafe,

§

impl<'a, S> Send for Builder<'a, S>
where S: Send,

§

impl<'a, S> Sync for Builder<'a, S>
where S: Sync,

§

impl<'a, S> Unpin for Builder<'a, S>
where S: Unpin,

§

impl<'a, S> UnwindSafe for Builder<'a, S>
where S: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.