LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Specifying an index for inserting elements in an existing queue

Hi,

 

Is it possible that I can insert elements in queue at a specific position ?

 

 

0 Kudos
Message 1 of 34
(7,379 Views)

I don't think you can do that easily, you have primitives to add LIFO (enqueue element at opposit end) or FIFO (enqueue element).

 

If you really need to do it ou could dequeue all elements, store them in an array, insert your element in the array and then put all the array elements in the queue, but this will be dangerous if other parts of your application can enqueue/dequeue element asynchronously.


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 2 of 34
(7,374 Views)

NO the basic rule for queue is FIFO will be wrong then

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 3 of 34
(7,364 Views)

Storing the elements in array and enqueing again would be dangerous because the same queue is accessed by multiple instances in my application.

 

Why I want to insert at a specific position is:

 

In my application, the enqueue operation will take place as per the user specified time and queue data will also be specified by user (there is no limit on data size).

Now at time instance#1, dataset#1 (suppose 10k elements) is updated in queue; at time instance #2, dataset#2 (more 10k elements) are inserted.

But when multiple instances access this queue, they cannot process dataset#2 until and unless dataset#1 is completed.

So I don't want this dataset size to be a limitation on the data processing functionality.

I want that "at time instance#2, dataset#2 be inserted in the middle of the queue".

So the queue is like 'Dataset#1 (5k elements)  Dataset#2 (10k elements) Dataset#2 (5k elements) Dataset#3 (n elememts)..'

 

Hope the problem statement is clear. Please share suggestion/thoughts.

 

Runjhun Agarwal.

0 Kudos
Message 4 of 34
(7,349 Views)

Runjhun,

 

i am not sure if i completly understand, what you are up to. The reason is mainly: When having a set of data (multiple elements), that data is usually stored as an array.

So it makes perfect sense to pass the whole array to the queue as one queue element instead of enqueueing each element of the data array as an individual queue element.

That being said, the option you are looking into is not possible at all since your queue has either no element or one element (data array) at a time.

 

What i can imagine that could prove useful to you is a "single element queue". It is a queue which contains exactly one element at any time. The reason: If i have to check/modify the data, i secure the data by enqueueing it (no element left, so each other de-queue function has to wait!). Once modified, passing back the data into the queue enables other readers to get access to the data, but only one at a time.

If your data is an array, you can manipulate your array to include the new data set "at any place (read: index)".

 

But on the other hand: How do you ensure that your data set is valid all the time if chuncking data in and out at any place all the time??????

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 5 of 34
(7,338 Views)

Thanks for the useful info Norbert.

 

But the hitch is; data elements in my data set are not always same.

Every element is different and represent a single entity. I cannot insert all the elements at once as they carry different and unique information.

 

In my application I am having enqueing logic at one place. And, the same queue is been dequeued by multiple other instances at the same time. So whichever instance gets the data firts will process the element information accordingly.

 

Hope this is much clear.

 

Runjhun.

0 Kudos
Message 6 of 34
(7,330 Views)

Runjhun,

 

a queue is a multiple writer/single reader construct. So reading your answer gives me the impression that you picked the incorrect method of distribution of data or your annplication requires a very unusual setup....

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 7 of 34
(7,325 Views)

Runjhun,

 

I agree with Norbert that a queue is likely not the best mechanism for transferring your data.  Please tell us more about your requirements so that someone can suggest a better appraoch.

 

Lynn

0 Kudos
Message 8 of 34
(7,315 Views)

Ok,

 

Now these answers are confusing meSmiley Indifferent

 

My requirement:

 

1. The user will specify what kind of data he/she wants to receive (it has lots of configuration option) And its not same everytime.

2. The configured data needs to be sent through a device. So there can be multiple devices that will send the data.

 

Now, after user completes the configuration, I write the cluster element in the queue. And the devices are accessing this queue and sending the data.

So its kind of single write/multiple reader.

 

For achieving this, do you suggest any other data exchange method. If a better method is available, i would be really excited to hear.

 

Runjhun

0 Kudos
Message 9 of 34
(7,303 Views)

Ok,

 

Now these answers are confusing meSmiley Indifferent

 

My requirement:

 

1. The user will specify what kind of data he/she wants to receive (it has lots of configuration option) And its not same everytime.

2. The configured data needs to be sent through a device. So there can be multiple devices that will send the data.

 

Now, after user completes the configuration, I write the cluster element in the queue. And the devices are accessing this queue and sending the data.

So its kind of single write/multiple reader.

 

For achieving this, do you suggest any other data exchange method. If a better method is available, i would be really excited to hear.

 

Runjhun

0 Kudos
Message 10 of 34
(7,303 Views)