Module tonari_actor::timed
source · Expand description
Tools to make a given actor able to receive delayed and recurring messages.
To apply this to a given (receiving) actor:
- Use
TimedContext<Self::Message>
asActor::Context
associated type.- Such actors cannot be spawned unless wrapped, making it impossible to forget wrapping it.
- Wrap the actor in
Timed
before spawning.
The wrapped actor will accept TimedMessage<M>
with convenience conversion from M
.
RecipientExt
becomes available for Recipient<TimedMessage<M>>
s which provides methods like
send_delayed()
, send_recurring()
.
Once accepted by the actor, delayed and recurring messages do not occupy place in actor’s channel inbox, they are placed to internal queue instead. Due to the design, delayed and recurring messages have always lower priority than instant messages when the actor is saturated.
See delay_actor.rs
example for usage.
Structs
- A wrapper around actors to add ability to receive delayed and recurring messages. See module documentation for a complete recipe.
Enums
- A message that can be delivered now, at certain time and optionally repeatedly.
Traits
- Convenience methods for
Recipient
s that acceptTimedMessage
s.