DEV: atomic strength for queues
This commit is contained in:
@@ -293,9 +293,14 @@ class ring_iterator<Iter_t, N, true> {
|
||||
return *this;
|
||||
}
|
||||
constexpr ring_iterator operator++(int) noexcept {
|
||||
ring_iterator it = *this;
|
||||
this->operator ++();
|
||||
return it;
|
||||
ring_iterator ret = *this;
|
||||
Iter_t itnew, it = iter_.load(std::memory_order_acquire);
|
||||
do {
|
||||
itnew = it;
|
||||
if (static_cast<size_t>(++itnew - base_) >= N)
|
||||
itnew = base_;
|
||||
} while (!iter_.compare_exchange_weak(it, itnew, std::memory_order_acq_rel));
|
||||
return ret;
|
||||
}
|
||||
//! @}
|
||||
|
||||
@@ -312,9 +317,14 @@ class ring_iterator<Iter_t, N, true> {
|
||||
return *this;
|
||||
}
|
||||
constexpr ring_iterator operator--(int) noexcept {
|
||||
ring_iterator it = *this;
|
||||
this->operator --();
|
||||
return it;
|
||||
ring_iterator ret = *this;
|
||||
Iter_t itnew, it = iter_.load(std::memory_order_acquire);
|
||||
do {
|
||||
itnew = it;
|
||||
if (--itnew < base_)
|
||||
itnew = base_ + N -1;
|
||||
} while (!iter_.compare_exchange_weak(it, itnew, std::memory_order_acq_rel));
|
||||
return ret;
|
||||
}
|
||||
//! @}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user