Upon terminating, an Actor sends a Last Ack Message to it's caller to notify it that the (nested) Actor has shut down.
Handle last Ack defines the behaviour of the calling Actor, when it receives a Last Ack Message.
Both sending the Last Ack and handling a Last Ack Message are part of the framework.
Every actor sends a Last Ack message to its parent when it stops. This message contains the state of the actor and an error report.
When the calling actor receives a last ack message it will execute the "Handle Last Ack Core" vi. By overriding this vi you can change the way it reacts when a nested actor stops.
In the "Handle Last Ack Core" vi you can "Read Error Report" to get the nested actors error so the caller can react to this e.g. restart the nested actor or shutdown the entire application.... If you don't override the it will read the error report and output it to the caller, so this is the vi that makes sure your caller gets the error of it's nested actor when that stopped.
Or you can use the "Read Actor" in your "Handle Last Ack Core" to get the nested actor's state and read out all the data if you have public property method to access its private data. The output of the "Read Actor" is of the type "Actor.lvclass" so you can use a "to more specific" to check which nested actor has stopped.
Hope this brief explanation helps you.
With the Last Ack message, you also get the nested actor's enqueuer. A given actor's enqueuer is unique, so you can use it to identify which of your nested actors just terminated.
Thanks a lot. I have one more doubt, I have handle error.vi and Handle last ack.vi in my parent actor. If my child actor stops due to error, it will be handled in the handle error.vi first, hence my error would be cleared there before entering the Handle last ack core.vi , then how will I get the error data of the closed child actor?
It is actually the other way around as you can see from the actor framework's MHL which is inside the actor core.vi
The Last Ack is handled first. If there is an error it will output it so that the Handle Error can handle it.
"Last Ack" is handled by the caller just like every other message. So the "Handle Last Ack Core" (which is inside the Do.vi of the Last Ack Message class) will be executed when the message is received. If this results in an error the "Handle Error" will be executed.
If you however clear this error by an override of the "Handle Last Ack Core" it won't reach the "Handle Error".
The "What a Software Architect needs to know when using the actor framework." gives a good overview of the common life cycle of an actor. It's on slides 31-32. Slide 49 also explains a bit more about your question on how to handle or report errors from nested actors.
Thanks, That was very clear. My further doubts are:
1. What happens to the error generated in the Parent itself? How does it differentiate between those called in its child and parent?
2. Can there be a communication between handle error.vi and its actor core so that some crucial error can be handled in Actor core?
Assume I have 5 nested actors. I have overrided Handle Last Ack core.vi in my parent VI. I need to check if the all the nested actors are closed, hence I plan to get the enqueuers of the nested actor in Handle Last Ack and maintaining it in an array. I will self stop the parent actor after all my nested actors are stopped. When I keep breakpoints in the case where enqueuers are added, the flow is correct and project gets stopped. But If I remove the breakpoints, my project does not gets stopped.
What could be the reason?
Can you suggest some alternate ways to implement this logic?
As you launch all of your nested actors, store their enqueuers in an array in your caller actor's private data. In Handle Last Ack, remove each enqueuer from the stored array. When the array is empty, do Send Stop Msg to your caller actor's self enqueuer (do this inside Handle Last Ack). That should work. If it doesn't, post a diagram of your Handle Last Ack code.