Jump to content

Accessing an array from two loops


eaolson

Recommended Posts

I'm cleaning up a quick-and-dirty app I wrote which is turning out to be something more useful than I originally expected. What I'm thinking of turning this into would have one loop running continuously doing data acquisition and periodically a user-fired event would save the data. Data will be stored in an array. So what I'm thinking of having a single element queue to store the array. The DAQ loop dequeues the array, appends the new element, and re-queues the array. The save loop can get a snapshot of the array at any time by previewing the array and saving it to disk. Attached is sort of a sketch of what I'm thinking of.

My concern is that in the dequeue-append-enqueue process, the Dequeue node has a buffer allocation on the output, I assume making a copy of what's in the queue. If the array gets large, I'm worried that will slow things down. On the other hand, I notice that neither the append or the enqueue has a buffer allocation. So maybe I'm misunderstanding where things are getting copied, and the queue is just pushing a pointer to the array around behind the scenes. Which is it? Or is there a better way of structuring this so the DAQ loop and the Save loop each have access to the same array?

(Right now, everything's in a single state machine and the user can't save the data without stopping the data acquisition.)

Link to comment

> My concern is that in the dequeue-append-enqueue process, the

> Dequeue node has a buffer allocation on the output, I assume

> making a copy of what's in the queue.

Once again: The "Show Buffer Allocations" do not show copies. They show buffer allocations. That dot on Dequeue indicates a place where a location is allocated to store data. Think of these as buckets. Data enqueued into a queue and dequeued from the queue elsewhere is not copied. It is moved from the bucket of the wire into the bucket in the queue and then moved from the bucket in the queue to the bucket on the new wire. The data is not copied; it is moved. When I say moved, I mean the top level data gets moved. For a double, that's an 8 byte value. For an array, that's a pointer, not the entire array. For a LVClass, it is also a pointer. For a cluster, it is the sum of top level data sizes of the clustered elements.

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