Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Actor communication with non AF processes.

Solved!
Go to solution

Hi All,

 

I have an application that runs a couple of state machines as independent processes. They communicate each other using User Events.

I’m trying to learn Actor Framework so I read a couple of resources and now I want to get my hands dirty with some code. I want to use my current application as a baseline and try to expand its capabilities by using actors.

 

I’ve a couple of questions:

 

  1. Do you recommend mixing Actor Framework with existing applications that don’t use AF?
  2. If I launch a root and some nested actors from my main application how can I start sending messages to the root actor? I don’t see a function in the AF API that allows me to do that.
  3. How can the root actor send a message without converting my main application to an actor?

Thanks!

0 Kudos
Message 1 of 2
(1,721 Views)
Solution
Accepted by Luis_CT

@tester2310 wrote:
  1. Do you recommend mixing Actor Framework with existing applications that don’t use AF?

Yes. But don't try to mix and match parts.

 

Option 1:

Start with your main app. Pick one module and convert it to a root actor, breaking out nested actors as needed. Make all the communication with that module go through the root actor. Don't try to cheat and have other lines of communication going to the actor or its nested actors. You'll defeat the whole point of the AF "clean lines" that protects you from a bunch of problems.

 

As you convert other modules, you make them into root actors with their own trees of nested actors. When two modules share a common root, make a new root class and change the existing actors into nested actors under that new root.

 

Option 2:

Create a new root actor whose only job is to call your application. Break a module out as a nested actor and change the application to send out messages to that nested actor. Repeat until all parallel activity is moved into a nested actor. Create further nested actors in their respective trees as needed.

 

This option has less rework involved but is sometimes harder to get started with.

 

 


@tester2310 wrote:
If I launch a root and some nested actors from my main application how can I start sending messages to the root actor?

The output of Launch Root Actor.vi is the enqueuer that you use to send messages into the root actor.

 

If the root actor needs to communicate out to your calling application, you add whatever communication mechanism you want/need into the private data of the root actor and populate that reference before you launch the actor. This is why Option 1 above is often more work -- you spend time making a good root actor with some custom communication mechanism, then you have to replace it with the caller enqueuer when you refactor it to be a nested actor.

 


@tester2310 wrote:
How can the root actor send a message without converting my main application to an actor?

See previous answer. Queues, notifiers, TCP, file refnums, globals... pick your poison for communication out of the root actor.

0 Kudos
Message 2 of 2
(1,693 Views)