Parcourir la source

Handle overflow write with overflow in disruptor

main
Ludovic 'Archivist' Lagouardette il y a 2 ans
Parent
révision
65b5be2c88
1 fichiers modifiés avec 6 ajouts et 0 suppressions
  1. +6
    -0
      LibSnugLog/include/disruptor.h

+ 6
- 0
LibSnugLog/include/disruptor.h Voir le fichier

@ -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(

Chargement…
Annuler
Enregistrer