max0x7ba / atomic_queue

C++ lockless queue.
MIT License
1.47k stars 176 forks source link

Bugfix : try_push blocks #26

Closed OlivierSohn closed 3 years ago

OlivierSohn commented 3 years ago

Hello,

Using the following queue:

  using Queue = atomic_queue::AtomicQueueB2<
  /* T = */ float,
  /* A = */ std::allocator<float>,
  /* MAXIMIZE_THROUGHPUT */ true,
  /* TOTAL_ORDER = */ true,
  /* SPSC = */ true
  >;

when the queue is full, try_push blocks.

A fix for this behaviour is here : https://github.com/OlivierSohn/cpp.algorithms/commit/37ccb8dbc95c0a1541073741166224b889a29e62

I verified that it solves my use case.

Feel free to use it!

max0x7ba commented 3 years ago

when the queue is full, try_push blocks.

Thanks for a tip, I'll see if I can reproduce it in a unit test.

max0x7ba commented 3 years ago

I added a unit test for try_push and it passes.

It is likely that the error was in your code, not the queue.

OlivierSohn commented 3 years ago

@max0x7ba Thanks for looking at it, I think the bug existed a year ago or so, and has been fixed since by a commit on master (or maybe I messed up something in my local version).

So I'll resync with master and everything will be fine ;)