Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling Actors From Non-Actor Code: Two Ways

Multiple threads in the Actor Framework forum have discussed how to call actors from non-actor code. I thought this was relatively straightforward (if sometimes tedious), but in long conversations at the Certified LabVIEW Architect Summit in Europe 2013, I got a better sense of what type of guidance many people were looking for.* Here then are two completely different mechanisms of calling an actor tree from non-actor applications.

  • The "By Ref Obj" method creates a shell around the actor such that it presents an API that looks/feels more like a traditional by-reference API, where methods are synchonous calls to a central object.
  • The "Marshaling" method creates a translation channel so that messages from the actor are marshaled into some other message processing system, like a queued message handler or an event structure.

I hope this information makes it easier to refactor existing systems to use more actors.

* It's amazing that a couple in-person talks can communicate more than months of online posts. It's why we have these summits... get your CLA and join us next year!

0 Kudos
Message 1 of 5
(10,645 Views)

Hi AQ, a comment on Integration By Ref Obj, based on my experience with similar "active objects":

I would suggest you use multiple notifiers in place of the DVR.  This is because one quite often needs to wait on an updated value.  For example, one might instruct the object to make a measurement, and then want to wait for the results of that measurement.  Or issue a command and then wait for the acknowledgment of successful completion of the command (with an error message if the command was unsuccessful).  With a DVR, there is no ability to wait on an updated value.

Another, possibly better, way to do this is with message replies, but that only works if the original actor is designed to support replies.

-- James

0 Kudos
Message 2 of 5
(4,124 Views)

I was struggling with this for a while. The By Ref implementation seems so obvious, now that I see it.

James, I had a similar thought, except with the addition of queues - which I use to buffer/store streamed data. AQ's example is just a template, right? No reason notifiers or queues can't be used, as long as thought is given to deadlocks, right?

0 Kudos
Message 3 of 5
(4,124 Views)

drjdpowell: Yes, what you're proposing would work, though if I needed a blocking message, I would just create some type of Reply Msg.lvclass that I can send to Shell Caller.lvclass. (Or use notifiers instead of queues in the reply message.)

0 Kudos
Message 4 of 5
(4,124 Views)

As for the marshaling way:

If you want to use the new root-and-nested API, you don't have access to the enqueuer of "Useful actor", so you have to get it back in the launch via a queue, or a message with reply.

I did it with a queue, posted here (saved in LV2012): Actor Integration_Marshaling (4.3.1).zip

Do tell me if there was something smarter to do !

0 Kudos
Message 5 of 5
(4,124 Views)