01-11-2019 04:28 AM
@Yeshwant_Biradar wrote:
Thanks for the quick reply!
You can use any datatype in a queue, also arrays
I mean to say that what if we replace queue by array to pass data from producer and consumer?
array also can store data , similarly we insert data in array like en-queue data in queue.
Queues are "unique" in that they support a many-to-one communication…
What does that mean ? Array also can be written by producer and can be read by one consumer
what is that array can not do over queue?
I hope now you get my question
How would you transfer the data from producer to consumer? Via a wire it'll be sequential, via a local you'll get race condition, through a queue you'll solve both problems.
Also, and this might be the reason for the question, a very big array (in the order of several GBs) might not be able to be allocated at once and separating data into chunks and storing them in a queue is a way to handle big data.
So, what's your use case?
/Y
01-11-2019 10:16 AM
Queues are pretty great in many ways and I use them whenever they make sense. Occasionally, they aren't the best choice. For example, if I need non-sequential access to a collection of data, I'm liable to start thinking in terms of an array (possibly packaged in an "Action Engine.")
As mentioned before, the "right" answer will depend on your particular use case.
-Kevin P