Jump to content

Obtain-Release-Obtain Queue?


FLAnatic

Recommended Posts

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.

post-11511-1221745909.jpg?width=400

Link to comment

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.

Link to comment

QUOTE (FLAnatic @ Sep 18 2008, 10:03 AM)

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.

Link to comment

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.

Link to comment

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...

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.