Examples

The odin_actor/examples directory contains a set of runnable example applications that each introduce and demonstrate a single odin_actor feature. It is recommended to go through examples in the following sequence:

  • hello_world : the basics (actorsystem, actor and sending messages)
  • sys_msgs : using system messages and timers
  • spawn : spawning one-shot async tasks from within actors
  • spawn_blocking : spawn blocking tasks (running in threads) from within actors
  • exec : using the generic exec(..) to execute closures within actor tasks
  • jobs : scheduling generic jobs with the actor system global JobScheduler
  • producer_consumer : point-to-point actor communication with MsgReceiver
  • pub_sub : publish/subscribe communication using a static MsgReceiverList<T>
  • dyn_pub_sub : dynamic publish/subscribe communication using DynMsgReceiver<T> and DynMsgReceiverList<T>
  • ping_pong : managing cyclic actor dependencies with PreActorHandle
  • query : using Query<Q,A> to send a message and wait for an answer
  • dyn_actor : dynamically create actors from within actors
  • actions : statically configure actor interaction with DataAction
  • dyn_actions : dynamically configure actor interaction with DynDataAction
  • retry : handling back-pressure with retry_send_msg(..)
  • requests : sequential processing of requests in background task
  • actor_config : configuring actors with the config_for!(..) macro
  • heartbeat : monitoring actor systems with heartbeat messages