Quantcast
Channel: One reader / one writer no-memory-allocation lock-free ring-buffer - Code Review Stack Exchange
Browsing latest articles
Browse All 6 View Live

Answer by ruds for One reader / one writer no-memory-allocation lock-free...

The Boost Single-Producer Single-Consumer Queue should meet your needs. If you're trying to use this for production code and you don't understand why your completely unsynchronized code is a bad idea,...

View Article



Answer by ruds for One reader / one writer no-memory-allocation lock-free...

As a general rule, if you don't have a strong grasp of the content in [intro.multithread] of the C++ standard, it's a bad idea to write or maintain lock-free code. In nearly all cases, the costs due to...

View Article

Answer by odinthenerd for One reader / one writer no-memory-allocation...

just as an example of possible race conditions consider the function:void WriteThread(int id) { std::chrono::milliseconds dura(1000 * id); std::this_thread::sleep_for(dura); myStruct* storage =...

View Article

Answer by ChrisW for One reader / one writer no-memory-allocation lock-free...

Use assignment instead of memcpyA better implementation of Obtain can return a non-const reference which you can assign to:T& Obtain() { return storage[curWriteNum & MASK];}Used like this:void...

View Article

Answer by ratchet freak for One reader / one writer no-memory-allocation...

there is absolutely no thread safety constructs, this means that you'll see a lot of interesting race conditions and memory inconsistencies just assuming dequeues happen fast enough does not mean they...

View Article


One reader / one writer no-memory-allocation lock-free ring-buffer

I have two threads - one thread queues items another thread dequeues. dequeue is fast enough and so we can assume that queue is never contains more than 65536 items.C++ doesn't contain "ring-buffer."...

View Article
Browsing latest articles
Browse All 6 View Live




Latest Images