Skip to main content

Task

Struct Task 

Source
pub struct Task<P> { /* private fields */ }
Expand description

A task to submit. Wraps TaskSpec and resolves times at submission.

Implementations§

Source§

impl<P> Task<P>

Source

pub fn new(payload: P) -> Self

A task with default settings: pool and kind "default", priority Normal.

Source

pub fn from_arc(payload: Arc<P>) -> Self

Like Task::new, sharing an existing Arc payload.

Source

pub fn spec(&self) -> &TaskSpec<P>

The underlying engine spec (times given relatively are resolved at submission).

Source

pub fn kind(self, k: impl Into<Arc<str>>) -> Self

Task kind: groups tasks for duration learning, metrics and tracing.

Source

pub fn pool(self, p: impl Into<Arc<str>>) -> Self

Pool to run in (default "default").

Source

pub fn priority(self, p: Priority) -> Self

Priority class (default Normal).

Source

pub fn key(self, k: impl Into<Arc<str>>) -> Self

Unique key: deduplicates submissions and can be referenced by dependents.

Source

pub fn deadline_in(self, d: Duration) -> Self

Soft deadline, relative to submission: urgency rises as it approaches.

Source

pub fn deadline_at(self, t: SystemTime) -> Self

Soft deadline at a wall-clock time.

Source

pub fn start_at(self, t: SystemTime) -> Self

Start at a fixed time (default tolerance 1s, run late if missed).

Source

pub fn start_in(self, d: Duration) -> Self

Start this long after submission (default tolerance 1s, run late if missed).

Source

pub fn start_tolerance(self, tol: Duration) -> Self

How late a fixed start may begin and still count as on time (any call order).

Source

pub fn on_miss(self, p: MissPolicy) -> Self

What to do if the fixed start is missed (any call order).

Source

pub fn duration_hint(self, d: Duration) -> Self

Expected run time, used before the engine has learned the kind’s durations.

Source

pub fn timeout(self, d: Duration) -> Self

Per-attempt timeout: the attempt is aborted and retried (if allowed) when it elapses.

Source

pub fn retry(self, r: RetryPolicy) -> Self

Retry policy (default: the pool’s).

Source

pub fn no_retry(self) -> Self

Run at most once.

Source

pub fn after(self, target: impl Into<TaskRef>) -> Self

Run after target succeeds.

Source

pub fn dep(self, d: Dep) -> Self

Add a dependency with an explicit edge condition.

Source

pub fn resource(self, name: impl Into<Arc<str>>, amount: u32) -> Self

Require amount units of a configured resource for each attempt.

Source

pub fn tag(self, k: impl Into<Arc<str>>, v: impl Into<Arc<str>>) -> Self

Attach a key/value label (visible to executors and in traces).

Source

pub fn tenant(self, tenant: impl Into<Arc<str>>) -> Self

The tenant this task belongs to, for weighted fair sharing of pools with PoolConfig::fairness.

Source

pub fn label( self, name: impl Into<Arc<str>>, value: impl Into<Arc<str>>, ) -> Self

Run only on workers labeled name = value (see Scheduler::set_group_capacity).

Trait Implementations§

Source§

impl<P> Clone for Task<P>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<P: Debug> Debug for Task<P>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<P> From<TaskSpec<P>> for Task<P>

Source§

fn from(spec: TaskSpec<P>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<P> Freeze for Task<P>
where TaskSpec<P>: Freeze,

§

impl<P> RefUnwindSafe for Task<P>

§

impl<P> Send for Task<P>
where TaskSpec<P>: Send,

§

impl<P> Sync for Task<P>
where TaskSpec<P>: Sync,

§

impl<P> Unpin for Task<P>
where TaskSpec<P>: Unpin,

§

impl<P> UnsafeUnpin for Task<P>

§

impl<P> UnwindSafe for Task<P>
where TaskSpec<P>: 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, dest: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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