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> Delay<M>where
M: Message,
impl<M> Delay<M>where M: Message,
sourcepub fn new(delay: Duration, message: M) -> UnattachedSource<Delay<M>>
pub fn new(delay: Duration, message: M) -> UnattachedSource<Delay<M>>
Schedules the timer to emit the provided message after delay
.
Creates an unattached instance of Delay
.
sourcepub fn until(when: Instant, message: M) -> UnattachedSource<Delay<M>>
pub fn until(when: Instant, message: M) -> UnattachedSource<Delay<M>>
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.
Availability
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§
Auto Trait Implementations§
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> !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