pub struct RepeatedTask<E> {
name: String,
cancel_token: CancellationToken,
inner: Mutex<TaskInner<E>>,
started: AtomicBool,
interval: Duration,
initial_delay: Option<Duration>,
}
Fields§
§name: String
§cancel_token: CancellationToken
§inner: Mutex<TaskInner<E>>
§started: AtomicBool
§interval: Duration
§initial_delay: Option<Duration>
Implementations§
source§impl<E: ErrorExt + 'static> RepeatedTask<E>
impl<E: ErrorExt + 'static> RepeatedTask<E>
sourcepub fn new(interval: Duration, task_fn: BoxedTaskFunction<E>) -> Self
pub fn new(interval: Duration, task_fn: BoxedTaskFunction<E>) -> Self
Creates a new repeated task. The initial_delay
is the delay before the first execution.
initial_delay
default is None, the initial interval uses the interval
.
You can use with_initial_delay
to set the initial_delay
.
pub fn with_initial_delay(self, initial_delay: Option<Duration>) -> Self
pub fn started(&self) -> bool
pub fn start(&self, runtime: Runtime) -> Result<()>
pub async fn stop(&self) -> Result<()>
Trait Implementations§
source§impl<E> Debug for RepeatedTask<E>
impl<E> Debug for RepeatedTask<E>
source§impl<E> Display for RepeatedTask<E>
impl<E> Display for RepeatedTask<E>
Auto Trait Implementations§
impl<E> !Freeze for RepeatedTask<E>
impl<E> RefUnwindSafe for RepeatedTask<E>
impl<E> Send for RepeatedTask<E>
impl<E> Sync for RepeatedTask<E>
impl<E> Unpin for RepeatedTask<E>
impl<E> UnwindSafe for RepeatedTask<E>
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
Mutably borrows from an owned value. Read more
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request