Hi Dmitry, Pondering the bounded MPMC queue at http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue (very clever design, by the way, as I've said before).
In the case where enqueue has made it all the way down to the copying of data_ (ie. found and reserved a cell, but not yet filled it or bumped the cell's next-sequence). If this copy throws an exception, as currently implemented it leaves the queue permanently broken (enqueue will skip past the cell and fill in later cells until the queue fills, and dequeue will halt and return "no more items" once it reaches that cell). Is there a multi-producer-safe way to "undo" the cell reservation made in the first part, to unblock the consumers without actually dequeuing an invalid item? The best I've come up with thus far is to add an extra "invalid" bool flag to cell_t, which is set true if the copy throws before still updating sequence_; if dequeue finds a cell with the flag set then it resets it and continues searching. I can't help wonder if there's a better way, though. (Using a reserved bit in sequence_ would also work, without the extra bool storage, but halves the max queue size and complicates the wraparound. It might technically be safer that way since it puts it under atomic protection; but I'm assuming a non-atomic bool field is safe due to rarity of use, x86 arch, and being stored prior to a nearby memory_order_release store and loaded after a corresponding nearby memory_order_acquire load.) -- --- You received this message because you are subscribed to the Google Groups "Scalable Synchronization Algorithms" group. To unsubscribe from this group and stop receiving emails from it, send an email to lock-free+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/lock-free/3710018e-e981-4a3d-a6b8-d83dcced1ba3%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.