10 #include "STMDAQ-TestBeam/utils/dataVars.hh"
12 #include "STMDAQ-TestBeam/utils/UDPsocket.hh"
15 #define RING_BUFFER_SIZE 65536
25 uint64_t try_push(
int chan, int16_t *
data, uint64_t n, uint64_t index);
28 void push(
int chan, int16_t *
data, uint64_t n);
31 uint64_t try_pull(
int chan, int16_t *&
data);
35 uint64_t pull(
bool *timeout,
int chan, int16_t *&
data);
38 std::atomic<int64_t> write[CHNUM];
40 std::atomic<int64_t> read[CHNUM];
42 std::atomic<int64_t> occupancy[CHNUM];
45 int64_t current_tail[CHNUM];
47 int64_t next_tail[CHNUM];
49 int64_t current_head[CHNUM];
52 int64_t write_num[CHNUM];
53 int64_t read_num[CHNUM];
56 static const int64_t size = RING_BUFFER_SIZE;
57 static const int64_t RING_BUFFER_NUM = RING_BUFFER_SIZE;
58 static const int64_t RING_BUFFER_LEN = RING_BUFFER_SIZE*UDPsocket::MAX_UDP_LEN;
64 int16_t* buffer[CHNUM];
67 int64_t increment(uint64_t n, uint64_t x){
68 return (n + x) % size;