Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Race condition preventing AF from reporting Actor errors?

lukepike, are you saying that you want to put the logic for handling a Lask Ack Msg into a method of the class that sent it? That seems like a violation of the "cone of responsibility": the decision of how to handle that message should be made by the caller actor and not the sender, since (1) the message is executed after the sender's lifetime and (2) the handling logic may be used to affect the internal state of the caller.

I do agree that casing on every possible type of sender for LA Msg is a pain, though. I haven't found a convenient workaround that maintains the cone of responsibility.

As an aside, I want to avoid editing Actor Framework.lvlib so my project stays on the main release trunk to get bug fixes and feature updates. I'll only entertain extensions to the framework via a child class.

0 Kudos
Message 11 of 15
(1,194 Views)

For lukepike's solution, there's no need to edit the framework. Just have the actors send a message to their caller that says "Actor type XYZ is done" as their last action before leaving their Stop Core.vi. You can use  the zero-coupling solution just like any other message to make it independent of the caller. The caller then has the equivalent of an interface implementation for each class of nested actor that it may get such a "I'm done" message from -- the same as you would have for any "I'm now in state Q" for all the other operations of the actors.

0 Kudos
Message 12 of 15
(1,194 Views)

Of course, lukepike's solution still doesn't address how to get the *caller* to be shutting down and still able to hear those messages, which is what my comments were addressing. His solution merely addresses responding to a nested actor shutting down, assuming the caller is still running.

0 Kudos
Message 13 of 15
(1,194 Views)

No, the logic belongs to the caller. All I'm saying is allow the caller to specify a child class of the Last Ack Message when launching any actor. This child class overides Do.vi, does the normal "to specific class" that all messages do, and calls a method on the caller like "Handle <whatever> Last Ack". This way, the the to more specific stuff is hidden and automated with the message maker, and all I have to do implement the last ack logic specific to the actor I launched.

0 Kudos
Message 14 of 15
(1,194 Views)

lukepike: You're essentially turning the Last Ack into a zero-coupling message itself. But there's a simpler way in this case...

It starts off just like you're thinking of doing with modifying the Last Ack message...

1) Create "MyNestedActor.lvclass"... all of your nested actors inherit from this.

2) Give this class a "Write Special Last Ack Message" and a "Read Special Last Ack Message".

3) During Stop Core.vi, fill in that Special Last Ack Message with any details you want to report.

But here's where it turns different. You're never going to send that message. Ever. Instead...

4) let the nested actor fire its Last Ack as it does today, with no changes.

5) In your caller's Handle Last Ack Core, get the Actor out of the Last Ack message and cast it as MyNestedActor and then call Read Special Last Ack Message.

6) Then call Do.vi on that message.

Same effect, no changes to the core framework.

0 Kudos
Message 15 of 15
(1,194 Views)