06-02-2021 11:26 PM
What is the right way and place to send message from nested actor to parent to tell that the nested actor is stopping? I want the parent to know that nested actor is quitting.
I tried to send message from nested actor's actor core helper loop when Events.stop is executed, but that seems to be too "late" and message is not sent.
If I send the message in nested actor's Stop Core (see pic) it works. But is it ok to send it like that?
I'm using LabView 2017.
06-03-2021 01:12 AM
06-03-2021 01:13 AM
Handle Last Ack Core.vi
Actor Framework already implements this. Overwrite this method in your root actor. Use "Read Actor.vi" to read the last state of your actor.
06-03-2021 03:34 AM
Thanks, I see that Handle Last Ack Core.vi is called on parent actor when nested actor stops.
If I have two different type of nested actors, how can I tell which one sent the last message?
06-03-2021 03:40 AM
As @cbutcher said: compare the enqueur. Or You can make cast to more specific class.
06-03-2021 04:03 AM
Got it to work, thanks.
06-03-2021 04:25 AM
For the sake of those coming to this post in the future, although neither of these examples specifically cover the OP's question, here are some overrides of Handle Last Ack Core I've used:
Here I use the enqueuer of the stopping Actor to deregister from a Registration Map (LabVIEW 2019 feature) that I use for sending data to various systems in a publish-subscribe type of arrangement. When the actor stops, no point in sending it more data!
If the Actor stops because of an error, I can also log why (usually they stop normally and just choose to disconnect).
Here I have a system that restarts an Actor when it stops (e.g. due to error, this is for a Network Stream handler that can be restarted for reconnection to produce a Server/Client setup).
Displayed below the Handle Last Ack Core is the method used to stop the relaunching (root, in this case) Actor when we want to actually stop, rather than keep relaunching.
In the case of this second example, you can see that the root/caller Actor has an enqueuer stored in private data with an easy-to-access unbundle. If your number of callee/nested Actors is small and they have specific purposes, you might also have a similar structure. In such a case, you can compare the enqueuer (seen in the first example, using "Read Caller-to-Actor Enqueuer.vi") with the bundled value to identify what stopped. Hopefully this clarifies what was previously written above (previously posting from a phone).
06-03-2021 09:05 AM - edited 06-03-2021 09:09 AM
@Waltteri wrote:I tried to send message from nested actor's actor core helper loop when Events.stop is executed, but that seems to be too "late" and message is not sent.
That makes no sense. As long as caller is still running, the message gets sent. Are you seeing an error reported by the Send node? The LastAck is intended to solve this issue, but your earlier solution should have worked... and sometimes is more useful pattern than relying on LastAck, so I don’t want people thinking it doesn’t work. Are you racing shutdown of the caller???