Testing a non-blocking queue

I have ported the psuedocode non-blocking queue here to C #. The code below is intended to be a close verbatim copy of the article.

What approach will you take to verify the implementation?

Note. I'm working in VS2010, so I don't have CHESS support yet.

Edit:

I removed the code in question, so some unsuspecting developer is not using it - it took quite a few changes to get it error-free ... and I still wasn't 100% sure it was error-free. brute force testing I couldn't get it to work better than a lock based solution.

Also, since I was targeting 3.5, I thought I was SOL with a 4.0 concurrent queue. The 3.5 RX framework includes a ConcurrentQueue, so it was a really fun little programming exercise and nothing more.

+2


a source to share


2 answers


If you are using VS 2010 and .NET 4 you can use ConcurrentQueue<T>

.



+2


a source


when i tried to create a non-blocking queue i checked the queue this way. I created 10 threads and called Enqueue 1000 times at the same time. At the end I checked the queue size, it was! = 10,000. Or sometimes it was throwing exceptions. Then I tried parallel relationship. The same result. This clearly means that the queue is not thread safe.



+2


a source







All Articles