Merge in SNORT/snort3 from ~UMASHARM/snort3:ring_atomic to master
Squashed commit of the following:
commit
8fb651860ecc4da16bb2aaed5728cc64bbd91573
Author: Umang Sharma <umasharm@cisco.com>
Date: Fri Jul 25 02:56:46 2025 -0400
helpers: RingLogic framework updated to use atomic than volatile
#ifndef RING_LOGIC_H
#define RING_LOGIC_H
+#include <atomic>
// Logic for simple ring implementation
class RingLogic
private:
int sz;
- volatile int rx;
- volatile int wx;
+ std::atomic<int> rx;
+ std::atomic<int> wx;
};
-inline RingLogic::RingLogic(int size)
-{
- sz = size;
- rx = 0;
- wx = 1;
-}
+inline RingLogic::RingLogic(int size) : sz(size), rx(0), wx(1)
+{}
inline int RingLogic::read()
{
inline int RingLogic::write()
{
int nx = next(wx);
- return ( nx == rx ) ? -1 : wx;
+ return ( nx == rx.load() ) ? -1 : wx.load();
}
inline bool RingLogic::push()