This project has moved. For the latest updates, please go here.

why List<T> with sync-lock operation since this is faster than ConcurrentQueue<T>?

Developer
May 28, 2014 at 6:44 AM
hello:
Recently,I am studying openPDC Source Code. I have some questions don't understand.
why List<T> with sync-lock operation since this is faster than ConcurrentQueue<T> on ProcessQueue?

Thanks for the help!
-zhengwen
Developer
May 28, 2014 at 2:15 PM
It depends on the specific use case. One item at a time, ConcurrentQueue<T> is approximately twice as fast. However, inside ProcessQueue<T> most of our processing is done in bulk. While they may be Queued 5 items at a time, they are usually dequeued much larger. It is these bulk operations that make a synchronized List<T> faster than ConcurrentQueue<T>.
Developer
May 29, 2014 at 1:39 AM
Thank you ,I've learned.
when processing is done in bulk ,it is these bulk operations that make a synchronized List<T> faster than ConcurrentQueue<T>.