Thursday, 22 August 2013

How does ConcurrentQueue work?

How does ConcurrentQueue work?

How does it work?
I know that, you put a type in, and then you can receive it on another
thread, and also get a bool at the same time.
But what i don´t get it, how does it send the item?
for example, in Thread 1, i have a byte array in which i write some data,
then put it into a Queue.
Then Thread 2, will use TryDequeue(out byte[]) to receive it. How does
this work?
As TryDequeue, will have to write it to another byte[], so i am guessing,
it´s doing some kind of copy?
Meaning, if the byte[] that Thread 1 is writing to is public, Thread 2 can
read to it faster/better as it doesn´t have to be copied?
Though the problem is that it doesn´t know when it´s allowed to read.

No comments:

Post a Comment