Skip to content

Commit

Permalink
refactor: add more static_assert(is_always_lock_free)
Browse files Browse the repository at this point in the history
  • Loading branch information
Swiftb0y committed Aug 18, 2024
1 parent 42ae999 commit e371390
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/control/controlvalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class ControlRingValue {
private:
T m_value;
mutable std::atomic<std::size_t> m_readerSlots;
static_assert(std::atomic<std::size_t>::is_always_lock_free,
"atomics used for lock-free data storage are not lock-free");
};

// Ring buffer based implementation for all Types sizeof(T) > sizeof(void*)
Expand Down Expand Up @@ -123,6 +125,8 @@ class ControlValueAtomicBase {
ControlRingValue<T> m_ring[cRingSize];
std::atomic<std::size_t> m_readIndex;
std::atomic<std::size_t> m_writeIndex;
static_assert(std::atomic<std::size_t>::is_always_lock_free,
"atomics used for lock-free data storage are not lock-free");
};

// Specialized template for types that are deemed to be atomic on the target
Expand All @@ -146,6 +150,7 @@ class ControlValueAtomicBase<T, cRingSize, true> {

private:
std::atomic<T> m_value;
static_assert(std::atomic<T>::is_always_lock_free);
};

template<typename T, std::size_t cRingSize = kDefaultRingSize>
Expand Down

0 comments on commit e371390

Please sign in to comment.