FLAnatic Posted September 19, 2008 Report Share Posted September 19, 2008 I'm looking at some code, and I'm not sure of the reasoning behind the way the Queues are being created. There are a few queues in the program which are all initially created this way. A queue is created and then destroyed right away, any errors are cleared, and then creates the queue again with he same name and data item and begins queuing items. Does anyone know why the initial Obtain->Destroy would be necessary? Maybe I'm missing something. Quote Link to comment
crelf Posted September 19, 2008 Report Share Posted September 19, 2008 QUOTE (FLAnatic @ Sep 18 2008, 10:03 AM) Does anyone know why the initial Obtain->Destroy would be necessary? Thinking out loud: The first VI either creates a new queue, or obtians an existing queue (if a queue of that name and datatype exists in memory) - I wonder if they're trying to make sure that if the queue already exists, it's destroyed, then recreated. Quote Link to comment
ned Posted September 19, 2008 Report Share Posted September 19, 2008 QUOTE (FLAnatic @ Sep 18 2008, 10:03 AM) I'm looking at some code, and I'm not sure of the reasoning behind the way the Queues are being created. There are a few queues in the program which are all initially created this way. A queue is created and then destroyed right away, any errors are cleared, and then creates the queue again with he same name and data item and begins queuing items. Does anyone know why the initial Obtain->Destroy would be necessary? Maybe I'm missing something. http://lavag.org/old_files/monthly_09_2008/post-11511-1221745909.jpg' target="_blank"> This looks like someone's workaround to a problem they were seeing because they couldn't (or didn't) find the root cause. Since this code uses named queues, it appears to ensure that there is not an existing, conflicting queue with the same name by attempting to get a reference to a queue with that name and then destroying it. Quote Link to comment
FLAnatic Posted September 19, 2008 Author Report Share Posted September 19, 2008 QUOTE (crelf @ Sep 18 2008, 09:23 AM) Thinking out loud: The first VI either creates a new queue, or obtians an existing queue (if a queue of that name and datatype exists in memory) - I wonder if they're trying to make sure that if the queue already exists, it's destroyed, then recreated. That's probably it! Thanks. Quote Link to comment
JustinThomas Posted September 19, 2008 Report Share Posted September 19, 2008 QUOTE (crelf @ Sep 18 2008, 07:53 PM) I wonder if they're trying to make sure that if the queue already exists, it's destroyed, then recreated. I don't think the queue would be destroyed if its already in memory as the Force Destroy terminal on the Release Queue vi is FALSE by default Quote Link to comment
FLAnatic Posted September 19, 2008 Author Report Share Posted September 19, 2008 QUOTE (JustinThomas @ Sep 18 2008, 09:31 AM) I don't think the queue would be destroyed if its already in memory as the Force Destroy terminal on the Release Queue vi is FALSE by default You are correct. I just tested your theory out by running a named queue in a loop in one VI and then created a second VI which obtained the named queue and then released the Queue. The queue in the original VI wasn't destroyed unless I set the Force destroy to "True" otherwise it kept running normally. Quote Link to comment
crelf Posted September 19, 2008 Report Share Posted September 19, 2008 QUOTE (JustinThomas @ Sep 18 2008, 10:31 AM) I don't think the queue would be destroyed if its already in memory as the Force Destroy terminal on the Release Queue vi is FALSE by default That's a good point. From the help: "force destroy? If FALSE (default) and you want to destroy the queue, either call the Release Queue function a number of times equal to the number of times you obtained a reference to the queue or stop all VIs using the queue reference. If TRUE, the function destroys the queue and you do not have to call the function multiple times or stop all VIs using the queue reference." In that case, I don't think that the extra code does anything... Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.