Skip to content

How to tell when all actors idle? #6177

Answered by Aaronontheweb
pwhe23 asked this question in Q&A
Discussion options

You must be logged in to vote

@pwhe23 best way to do this would be a "roll up" process:

  1. Each individual actor uses a ReceiveTimeout to test for when it has become idle;
  2. Parent actor manages all of the worker actors that use the ReceiveTimeout - parent actor calls Context.Watch on each child so it will receive a Terminated message when that child actor dies;
  3. When each child receives its ReceiveTimeout message, it kills itself via Context.Stop - parent receives the Terminated message and then calls Context.GetChildren (or decrements an internal counter) to see how many children are still alive.
  4. When the parent actor notices that the number of living children == 0, parent actor can kill itself or shut down the entire Ac…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@Aaronontheweb
Comment options

Answer selected by pwhe23
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants