Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Question: Actor framework, communication tree and stopping actors

My question is about how to stop an Actor Framework system gracefully. I think tha I need to learn more about its communication tree. 

In the basic framework template, there are three actors (one root, aplha and beta).  The system operates well. Now I want to add another actor or to launch more than one copy of one. 

For example, if I modify the root actor and launch there two copies of the beta actor, it doesn't shut down properly. When I press stop, the root actor stops but none of the others (Alpha, Beta 1 or Beta2) stop. 

I see in the Simple Actor example, each copy of the actor receives a separate stop message. But in the Actor Framwork template, a stop is sent only to the root actor queue (and apparently it gets propagated to the others). This propagation seems to be interrupted by my modification.

Please let me know where I can learn more about the messaging and stopping Actor components. Thank you very much.

Steve

0 Kudos
Message 1 of 4
(4,906 Views)

There's more than one way to do this, so I'll just speak about the method I usually use.  AF explicitly supports shutting down an actor that launched other actors while keeping those launched actors running.

Typically, I will have an actor keep track of the nested actors it launches.  When calling actor exits, it either transfers responsibility for those nested actors to another actor, or will shut them down.  The shutdown in my systems occurs in the Stop Core override.   In this VI, the actor will send a shutdown message to each of the nested actors it is responsible for.  The Stop Core for these actors should be implemented in the same way.  This gives a top-down shutdown sequence that is fairly simple to implement.  It is not, however, the right choice for all applications.

There are more complex ways of doing this (for example, not stopping a calling actor until all of the nested actors it is responsible for have sucessfully shut down, thus effecting a bottom-up shutdown sequence), but this is a reasonable place to start.

Cheers,

Matt Pollock
National Instruments
Message 2 of 4
(3,909 Views)

When you launch nested actors you should have their enqueuer stored in the private data of the actor that launched them.  In the example the root actor should store the enqueuers for Alpha, Beta 1 and Beta 2.  Next you override the Stop Core.vi for Root to send Normal or Emergency Stop messages to Alpha, Beta 1 and Beta 2.  Then when Root stops it stops the nested Alpha and Beta 1,2 actors.  This method has the effect of shutting down Root first and then just going on faith that Alpha, Beta 1 and Beta 2 all stop on their own.

What Matt was talking about regarding the more complex way can be summarized this way:

Send a stop message to Root.  Root changes a boolean in its private data (perhaps "Stopping") to True.  Then Root sends Alpha and Beta 1 and Beta 2 actors stop messages.  When actors stop they send a Last Ack.  In Root you override Handle Lask Ack.vi to account for the shutting down of the Alpha, Beta1 and Beta 2 actors.  Root has logic to keep track and ensure that of all the nested actors have sent a last ack.  When all the nested actors stop then you can have root send itself a stop.  In this manner Root takes some responsibility for the stopping of its nested actors.

Dave Staab had a nice presetation of this at NIWeek.  I think his slides are on the site somewhere...

Casey

Casey Lamers


Phoenix, LLC


casey.lamers@phoenixwi.com


CLA, LabVIEW Champion


Check Out the Software Engineering Processes, Architecture, and Design track at NIWeek. 2018 I guarantee you will learn things you can use daily! I will be presenting!

Message 3 of 4
(3,909 Views)

Dave Staab had a nice presetation of this at NIWeek.  I think his slides are on the site somewhere...

Casey

Perhaps this one?

https://decibel.ni.com/content/docs/DOC-30870

Cheers,

Matt Pollock
National Instruments
0 Kudos
Message 4 of 4
(3,909 Views)