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>
impl<'a, S: Schedule + 'static> Builder<'a, S>
Sourcepub fn name(self, name: &'a str) -> Self
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.
Sourcepub fn kind(self, kind: &'static str) -> Self
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 —
kind
s 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”.
Sourcepub fn location(self, location: Location<'a>) -> Self
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.
Sourcepub fn spawn_allocated<STO, F>(
&self,
task: STO::StoredTask,
) -> JoinHandle<F::Output> ⓘ
pub fn spawn_allocated<STO, F>( &self, task: STO::StoredTask, ) -> JoinHandle<F::Output> ⓘ
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>
impl Builder<'_, &'static LocalStaticScheduler>
Sourcepub fn spawn_local_allocated<STO, F>(
&self,
task: STO::StoredTask,
) -> JoinHandle<F::Output> ⓘ
pub fn spawn_local_allocated<STO, F>( &self, task: STO::StoredTask, ) -> JoinHandle<F::Output> ⓘ
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>
impl<S: Schedule + 'static> Builder<'_, S>
Sourcepub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output> ⓘ
pub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output> ⓘ
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>
impl Builder<'_, &'static LocalStaticScheduler>
Sourcepub fn spawn_local<F>(&self, future: F) -> JoinHandle<F::Output> ⓘ
pub fn spawn_local<F>(&self, future: F) -> JoinHandle<F::Output> ⓘ
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>
impl Builder<'_, LocalScheduler>
Sourcepub fn spawn_local<F>(&self, future: F) -> JoinHandle<F::Output> ⓘ
pub fn spawn_local<F>(&self, future: F) -> JoinHandle<F::Output> ⓘ
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.
Sourcepub fn spawn_local_allocated<STO, F>(
&self,
task: STO::StoredTask,
) -> JoinHandle<F::Output> ⓘ
pub fn spawn_local_allocated<STO, F>( &self, task: STO::StoredTask, ) -> JoinHandle<F::Output> ⓘ
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§
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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)