Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Using parent class accessor in child Actor Core

Hello,

 

I stumbled over some unexpected behaviour while trying to access parent class data using an accessor in the Actor Core of the child class.

 

Here's an outline of my project:

  • There is a parent class 'Client UI' which handles the connection to a remote proxy using Network Endpoint Actor.
  • Once the connection is established, I save the proxy enqueuer to 'Client UI's private data.
  • I created a 'Read Proxy Enq.' method to enable child actors of 'Client UI' to send messages to the proxy actor.
  • A child actor, e.g. 'Cam UI' which inherits from 'Client UI' should now be able to call 'Read Proxy Enq.'

However, I noticed that 'Read Proxy Enq.' returns an invalid enqueuer if called from 'Cam UI's Actor Core. If I call 'Read Proxy Enq.' in one of 'Cam UI's methods it works as expected.

 

Any idea what I might be missing?

Thanks in advance!

0 Kudos
Message 1 of 8
(3,937 Views)

First guess: your call from Actor Core returns an invalid enqueuer because the correct data value has not been written to the private data yet (Race Condition) or 'Read Proxy Enq." is being passed a "wrong" object...

 

Can you post a screenshot of your Actor Core?

 

 

0 Kudos
Message 2 of 8
(3,925 Views)

Thanks, I think I figured it out: Race condition was the key word.

I think, 'Cam UI's Actor Core runs before 'Client UI's (?). But since I launch the Network Endpoint Actor as a nested actor in 'Client UI's AC, the enqueuer reference is still invalid at the time 'Cam UI's AC wants to access it.

 

Which makes me wonder if that is always the case or if all ACs of parent and child actors run at the same time?

 

0 Kudos
Message 3 of 8
(3,910 Views)

@pktl2k wrote:

...

I think, 'Cam UI's Actor Core runs before 'Client UI's (?). But since I launch the Network Endpoint Actor as a nested actor in 'Client UI's AC, the enqueuer reference is still invalid at the time 'Cam UI's AC wants to access it.

 


Yes and No.... Data Flow-wise, "Cam UI's Actor Core will start executing until the Parent Call of Actor Core.vi is reached

(Note: for the ease of understanding I'm ignoring parallel loops in Actor Core.vi at this time).

The Parent Call will jump to 'Client UI's Actor Core.vi, again executing is to the Actor Core call of its' parent calls... eventually executing the message handling loop of the ultimate Actor Core.vi of the Actor class.

 

I think your race condition happens somewhere along the way.... maybe the enqueuer written to the object in ClientUI:Actor Core.vi before invoking the parent call....

 

I have to admit I am not very confident with the Network Endpoint Actor.

 

 

 

0 Kudos
Message 4 of 8
(3,903 Views)

Unless you can prove otherwise, it's not a race condition. Proxies are established in Actor Core, so any attempt to access that before passing the object along to the Call Parent Node will fail. Nothing racy about it -- it's completely deterministic.

 

I get a bit twitchy about people claiming "race condition". If one existed, that would be a severe bug that we would need to patch. This is just an order of operations problem as far as I can tell. Please post evidence if you see such to the contrary.

Message 5 of 8
(3,892 Views)

@AristosQueue (NI) wrote:

Unless you can prove otherwise, it's not a race condition. Proxies are established in Actor Core, so any attempt to access that before passing the object along to the Call Parent Node will fail. Nothing racy about it -- it's completely deterministic.



You're right, to call this a race Condition is wrong. Smiley Embarassed

 

 

0 Kudos
Message 6 of 8
(3,883 Views)

No, not a race condition. Just ignorance about which part runs first.

Thanks for your insight!

0 Kudos
Message 7 of 8
(3,873 Views)

*phew* 🙂

Message 8 of 8
(3,866 Views)