Struct maitake::task::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,

Available on crate feature alloc only.

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,

Available on crate feature alloc only.

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,

Available on crate feature alloc only.

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

Available on crate feature alloc only.

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> 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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T> Instrument for T

§

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

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

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,

§

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

§

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more