Open mingpepe opened 7 years ago
the threadsanitizer should help identifying the bug ... I'll give a look later this week
there is a problem in the algorithm when the tail reaches the head while the head is being updated. I applied a quick fix which should make your test work and make the queue work consistently (for what I have been able to test so far). I had to make some changes to the algorithm though and there is something I don't quite like at the moment : the algorithm now requires size + 1 pages to work properly the writers are now synchronized
I have some ideas on how to change the algorithm to get rid of this two limitations but will probably need some time to code and test those (it's a hectic period).
Even if in theory the race condition shouldn't be there anymore I'll keep this bug open until I'll push those changes
I also included your test in the rqueue unit tests
The number of successfully read from rqueue sometimes less than the number of successfully write to rqueue.
Here is the test code. https://gist.github.com/mingpepe/9d6ec5f17bdb60094d7fc980df3437ce
But i am not found the bug yet.