pub struct Delay<M> { /* private fields */ }Expand description
A source that emits a message after some specified time.
§Tracing
The emitted message continues the current trace.
§Example
use elfo::time::Delay;
#[message]
struct MyTick;
while let Some(envelope) = ctx.recv().await {
msg!(match envelope {
SomeEvent => {
ctx.attach(Delay::new(ctx.config().delay, MyTick));
},
MyTick => {
tracing::info!("tick!");
},
});
}Implementations§
Source§impl<M: Message> Delay<M>
impl<M: Message> Delay<M>
Sourcepub fn new(delay: Duration, message: M) -> UnattachedSource<Self>
pub fn new(delay: Duration, message: M) -> UnattachedSource<Self>
Schedules the timer to emit the provided message after delay.
Creates an unattached instance of Delay.
Sourcepub fn until(when: Instant, message: M) -> UnattachedSource<Self>
Available on crate feature unstable only.
pub fn until(when: Instant, message: M) -> UnattachedSource<Self>
unstable only.Schedules the timer to emit the provided message at when.
Creates an unattached instance of Delay.
§Stability
This method is unstable, because it accepts tokio::time::Instant,
which will be replaced in the future to support other runtimes.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Trait Implementations§
Source§impl<M: Message> SourceHandle for Delay<M>
impl<M: Message> SourceHandle for Delay<M>
Source§fn is_terminated(&self) -> bool
fn is_terminated(&self) -> bool
Returns
true if the source has stopped producing messages.Source§fn terminate_by_ref(&self) -> bool
fn terminate_by_ref(&self) -> bool
Terminates the source.
Drop is called immediately. Read moreAuto Trait Implementations§
impl<M> Freeze for Delay<M>
impl<M> !RefUnwindSafe for Delay<M>
impl<M> Send for Delay<M>where
M: Send,
impl<M> Sync for Delay<M>where
M: Sync,
impl<M> !Unpin for Delay<M>
impl<M> UnsafeUnpin for Delay<M>
impl<M> !UnwindSafe for Delay<M>
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