Browse Source

Handle overflow write with overflow in disruptor

main
Ludovic 'Archivist' Lagouardette 2 years ago
parent
commit
65b5be2c88
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      LibSnugLog/include/disruptor.h

+ 6
- 0
LibSnugLog/include/disruptor.h View File

@ -119,6 +119,12 @@ public:
} else if constexpr (OverflowStrategy::on_overflow == overflow_response_t::must_overflow) { } else if constexpr (OverflowStrategy::on_overflow == overflow_response_t::must_overflow) {
if(!fence.compare_exchange_weak(fence_v, new_offset, std::memory_order_release, std::memory_order_relaxed)) { if(!fence.compare_exchange_weak(fence_v, new_offset, std::memory_order_release, std::memory_order_relaxed)) {
return std::nullopt; return std::nullopt;
} else {
offset_t v;
do {
v = read_lead.load(std::memory_order_acquire);
if(v >= new_offset) break;
} while(read_lead.compare_exchange_weak(v, new_offset, std::memory_order_release, std::memory_order_relaxed));
} }
} else { } else {
static_assert( static_assert(

Loading…
Cancel
Save