Skip to main content

ScheduledTaskGroup

Struct ScheduledTaskGroup 

Source
pub struct ScheduledTaskGroup { /* private fields */ }
Expand description

Represents scheduled task group.

Implementations§

Source§

impl ScheduledTaskGroup

Source

pub fn new(group: TaskGroup) -> Self

Creates a new ScheduledTaskGroup.

Source

pub fn group(&self) -> &TaskGroup

Returns the group.

Source

pub fn schedule<F, Fut>( &self, config: ScheduledTaskConfig, policy: ScheduledExecutionPolicy, task: F, ) -> RuntimeResult<ScheduledTaskRegistrationOutcome>
where F: FnMut() -> Fut + Send + 'static, Fut: Future<Output = ()> + Send + 'static,

Schedules task with the cadence of config and the run limits of policy.

The driver and runs belong to this group and stop when it is cancelled. A fixed-delay schedule runs task on its driver; a fixed-rate schedule starts each run as its own task once a run slot is free. A duplicate name leaves the existing registration unchanged.

§Errors

Returns an unsupported error when the period is zero or policy contradicts the mode of config: fixed-delay and non-overlapping schedules need a serial policy, an overlapping schedule needs a bounded one. Returns an operational error when the driver cannot be spawned.

Source

pub fn schedule_operation<F, Fut>( &self, operation: &OperationContext, config: ScheduledTaskConfig, policy: ScheduledExecutionPolicy, task: F, ) -> RuntimeResult<ScheduledTaskRegistrationOutcome>
where F: FnMut() -> Fut + Send + 'static, Fut: Future<Output = ()> + Send + 'static,

Schedules task like Self::schedule as part of a bounded operation.

The driver and runs are registered with this group’s fixed component owner and stop when the operation is cancelled or reaches its deadline.

§Errors

Returns the same errors as Self::schedule.

Source

pub fn schedule_controlled<F, Fut>( &self, config: ScheduledTaskConfig, task: F, ) -> RuntimeResult<ScheduledTaskRegistrationOutcome>
where F: FnMut() -> Fut + Send + 'static, Fut: Future<Output = ScheduledTaskControl> + Send + 'static,

Schedules fixed-delay work that can end its own schedule.

The schedule stops after a run returns ScheduledTaskControl::Stop.

§Errors

Returns an unsupported error when the period is zero or config is not a fixed-delay schedule, and an operational error when the driver cannot be spawned.

Source

pub fn snapshot(&self) -> Vec<ScheduledTaskSnapshot>

Returns the snapshot.

Source

pub fn observer(&self, names: &[&str]) -> ScheduledTaskObserver

Observes a fixed selection of schedule names without keeping tasks alive.

Duplicate names are removed. Callers should select component-level jobs, not names derived from requests or resources.

Source

pub fn clear_completed(&self) -> RuntimeResult<()>

Clears completed schedule registrations so a fixed component owner can start a new operation generation with the same schedule names.

§Errors

Returns an error while the component group still has active tasks.

Source

pub async fn shutdown(&self, timeout: Duration) -> ShutdownReport

Shuts down the owned service.

Source

pub async fn shutdown_until(&self, deadline: ShutdownDeadline) -> ShutdownReport

Shuts down the owned service using one absolute deadline.

Trait Implementations§

Source§

impl Clone for ScheduledTaskGroup

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 Debug for ScheduledTaskGroup

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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