Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Helper loop tutorials

Solved!
Go to solution

Hi Guys,

 

Did some searching, but haven't yet grasped them well. Does someone have some links for good design/use of "helper loops"? 

 

I am going to be communicating with hardware that occasionally takes non-zero time to do the task I tell it -- seems like the use case for a helper loop within the actor for such hardware.

 

Thanks,

 

-WavePacket

0 Kudos
Message 1 of 7
(365 Views)
Solution
Accepted by topic author WavePacket

Here are a few that I bookmarked or found helpful in my own search:

 

https://www.mooregoodideas.com/actor-framework/basics/AF-basics-part-4/index.html

https://forums.ni.com/t5/Actor-Framework-Discussions/Stopping-a-running-loop-inside-a-nested-actor-t...

https://www.hampel-soft.com/blog/dqmh-actors-self-messaging-or-helper-loops/

https://kosist.org/2021/01/actor-framework-how-to-stop-helper-loop-of-actor-core-method/

https://forums.ni.com/t5/Actor-Framework-Discussions/What-is-a-good-way-to-repeat-start-and-stop-und...

 

Cumulatively, they've helped me get a germ of an understanding of choosing between

- helper loop vs dedicated nested actor

- helper loop vs Time-Delayed Send Message.

And, of course, the recommended way to stop a helper loop when used: The Actor QMH decides when to stop it as opposed to the helper deciding for itself.

0 Kudos
Message 2 of 7
(333 Views)

@Dhakkan wrote:

Here are a few that I bookmarked or found helpful in my own search:

...

Cumulatively, they've helped me get a germ of an understanding of choosing between

- helper loop vs dedicated nested actor

- helper loop vs Time-Delayed Send Message.

And, of course, the recommended way to stop a helper loop when used: The Actor QMH decides when to stop it as opposed to the helper deciding for itself.


Thanks. I had only come across 2 of those 5 links before and I read the other 3 and I definitely learned a few things. It would help me (and probably the others who google this thread) if you shared your way to decide between helper loop, dedicated nested actor, and time-delayed send message. Would you mind sharing? 

 

For the fun of it & despite being relatively naive I'll make a flailing attempt at choosing between the architectures:

1. Time-delayed send message is fine with the rate of executing a message module is significantly lesser than both the cumulative rate of all other incoming messages, and also the rate associated with the time-delayed data. Basically here your actor is free most of the time, and adding this message doesn't cost anything. 

 

2. Helper loops - these seem useful when the message takes a while? At-least here you can still have a responsive actor.

 

3. Dedicated nested actor - Maybe when you need the asynchronous behavior that AF delivers? Not really sure here...

 

0 Kudos
Message 3 of 7
(313 Views)

@WavePacket  escreveu:

3. Dedicated nested actor - Maybe when you need the asynchronous behavior that AF delivers? Not really sure here...

 


Really good material over there.

 

About question 1 and 2 you are correct to assume that. Although time-delayed messages can be a trouble to debug, make sure you taking care of their execution and the reference.

 

About question 3, it ends up being all about design. Do you want to separate the tasks between your actors? One actor collects data, another one processes it, the other orchestrates. It depends on time constraints, hardware, etc...

 

Also remember, Helper Loops are not mandatory, you might not even need to override Actor Core. Think carefully and test always.

 

Regards,

Message 4 of 7
(292 Views)

@WavePacket

 

I embraced commercial use of the Framework only recently in the past couple of months. Primary reason: Formal AF training; and LabVIEW interfaces simplified the creation of abstract messaging. (Packaging the interfaces and naming them has been a bit of a learning curve though.)

 

You and Felipe pretty much covered the thought process behind the selection of one implementation over another. In trying to find a use case for metronomes (my consideration for dedicated nested actors), I chanced upon two more excellent links.

 

https://forums.ni.com/t5/Past-NIWeek-Sessions/NIWeek-2013-What-a-Software-Architect-Needs-to-Know-Wh...

https://forums.ni.com/t5/Actor-Framework-Discussions/Timed-delayed-message/td-p/3404893?profile.lang...

 

The first link is pretty much self explanatory. The second link was the result of my search for metronomes. Basically, in CAN-like messaging, there is a typical need to send periodic data packets (frames); sometimes concurrently at differing intervals. To me, in those situations, one or more 'Timer' nested actors would provide dedicated 'ticks' (of course, subject to the OS jitters).

0 Kudos
Message 5 of 7
(269 Views)

So from here"The do for that message should send a stop command to the helper loop. That command could be via user event, notifier, etc."

 

Right now, those two are the only ways that I know how to handle delagating a task to the helper loop. Are there other actor-helper loop communication implementations that are good to know about?

0 Kudos
Message 6 of 7
(260 Views)

I believe you can use any of the inter-loop communications that use references - queues, events, notifiers, DVRs (hopefully not), channels - whatever you are comfortable with. Just know that this facilitates communication from the actor to its helper. For the reverse direction, you will likely need to implement messages to 'self'.

0 Kudos
Message 7 of 7
(239 Views)