01-27-2016 07:37 AM
I have the following situation: my main VI initializes an actor, and launches it as the root actor. The actor has opened some queue references during initialization, before launch. The queues are used for cleanup, which is called by actor's Stop Core.
To stop execution, I have my main VI send a Stop message to the root actor, and the VI stops. However I see errors 1 during cleanup when using actor's queue. It seems to be a race condition: the actor's queue references become invalid before Stop core executes, making the cleanup function fail. I assume it's because the main VI owns the queue references, and when it stops it makes them invalid.
Is my understanding correct?
How can I solve it, without making an awkward notification mechanism so that the main VI waits for actor shutdown?
I use LV2014.
01-27-2016 08:22 AM
CharlesB64 schrieb:
To stop execution, I have my main VI send a Stop message to the root actor, and the VI stops. However I see errors 1 during cleanup when using actor's queue. It seems to be a race condition: the actor's queue references become invalid before Stop core executes, making the cleanup function fail. I assume it's because the main VI owns the queue references, and when it stops it makes them invalid.
On invoking an Actor, it creates its own queue (the Actor enqueuer being returned by the launch VI). This particular queue is valid as long as the Actor is alive. On sendig a Stop message to the Actor, it terminates and destroys its enqueuer. This means that after having send the stop message you basically should not use the Actors enqueuer anymore.
In my opinion, the Stopping mechanism in the AF is designed bullet proof as long as you don't mess up the routines on your own.
Hope I haven't misunderstood your question. If so, pleas post a screen shoot to better describe the issue
01-27-2016 08:45 AM
I'm not talking about the actor's enqueuer, but my own queues that I create during object initialization, and that should still be available during actor's Stop core.
01-27-2016 08:54 AM
Sorry, seems I didn't get this bit.....
So you are obtaining those queues in PreLaunch Init.vi, right? And you are saving those Q refs in the Actors private data using a bundle or an In Place?
01-27-2016 09:12 AM
I initialize them in a separate VI called before launching the actor, not in Pre launch init. Maybe that's what I should do to solve the problem
01-27-2016 09:17 AM
Pre Launch Init.vi is usually the place to initialize things. You could as well perform some initialization in your Actors' implementation of Actor Core.vi before calling the parents' implementation.
The important thing is that you have to make sure, the Q refs are neatly stored in the Actors' private data, from where it ia accessible.