Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to handle shared resources in AF

OK, so there is one problem with that method above - if an actor fails at pre-init, then the last ack is never sent.  I realize now, I have done this before - I had a list of booleans that was paired with the queues, and rather than removing actor enqueuers, I simply toggled the boolean to indicate whether the actor was present or not.  But, three has to be a way to adjust the above code so that it can account for an actor fail at pre-init?  I will think on this...

0 Kudos
Message 11 of 18
(2,145 Views)

A fail at pre-launch init should cause an error to be returned from Launch Actor.  Watch for that error and never add the enqueuer for the failed actor to the list in the first place.

Cheers,

Matt Pollock
National Instruments
0 Kudos
Message 12 of 18
(2,145 Views)

I'll be lazy and not look yet, so feel free to disregard this message Matt if you choose, but where is the error picked up?  If I use the Launch Nested Actors VI, I don't believe failure here will reverberate through the root actor (i.e. there is no error that can be picked up where the actor is launched).  But, I am likely mistaken.  I will take a closer look at this.

0 Kudos
Message 13 of 18
(2,145 Views)

Actually, it is picked up.  Dig into Launch Nested Actor, then down to Launch Actor Core.  There is a queue that is used to pick up any errors reported from Pre-Launch Init.  You can see how it works if you dig down into Actor.vi - an error sent out from Pre-Launch Init will make it all the way back up to the caller of Launch Nested Actor.

prelaunch error.JPG

Cheers,

Matt Pollock
National Instruments
0 Kudos
Message 14 of 18
(2,145 Views)

Great!  Thanks a lot, Matt!  I will take a look at this. Matt

0 Kudos
Message 15 of 18
(2,145 Views)

OK...This works great and I learned something in the bargain that seems simple enough but was killing me - if you try to loop through an array of size 0 and expect an error to be passed through, think again...I know this is going to bite me again in the near future, but c'est la vie.  Thanks a lot, AQ and Matt.

m

0 Kudos
Message 16 of 18
(2,145 Views)

Just a note about the 0 sized array in a for loop: You can guarantee any wire to get through if you use shift registers. I always use shift registers for my error wires, as well as for my class wires. In case of 0 iterations the initial value will be passed thorough.

0 Kudos
Message 17 of 18
(2,145 Views)

When you drop a For Loop around existing code, starting in LV 2014, LV automatically adds shift registers instead of tunnels for error wires. That helps by catching one of the ways you get into this problem.

You need to use shift registers for refnums that you expect to pass through also.

0 Kudos
Message 18 of 18
(2,145 Views)