浏览代码

Handle overflow write with overflow in disruptor

main
Ludovic 'Archivist' Lagouardette 2 年前
父节点
当前提交
65b5be2c88
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. +6
    -0
      LibSnugLog/include/disruptor.h

+ 6
- 0
LibSnugLog/include/disruptor.h 查看文件

@ -119,6 +119,12 @@ public:
} 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)) {
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 {
static_assert(

正在加载...
取消
保存