22 #ifndef _RTEML_READER_H_ 23 #define _RTEML_READER_H_ 119 template <
typename B>
121 : buffer(_buffer), top(0), bottom(0), timestamp(0) {}
123 template <
typename B>
127 typename B::event_t event_next;
131 if (buffer.read(event, bottom) != buffer.OK)
135 bottom = (size_t)(bottom + 1) % (buffer.size + 0);
136 if (buffer.read(event_next, bottom) == buffer.OK)
137 timestamp = event_next.getTime();
140 DEBUGV3(
"pull-> %d (%d,%d)\n", length(), bottom, top);
145 return (length() > 0) ? AVAILABLE : UNAVAILABLE;
148 template <
typename B>
154 buffer.read(event, --top);
155 else if (top - 1 <= 0) {
157 buffer.read(event, top);
161 DEBUGV3(
"pop-> %d (%d,%d)\n", length(), bottom, top);
166 return (length() > 0) ? AVAILABLE : UNAVAILABLE;
177 buffer.state(b, t, ts);
179 if (timestamp > ts) {
195 typename B::event_t event;
198 buffer.read(event, bottom);
199 if (timestamp < event.getTime())
206 return (top >= bottom) ? top - bottom : (buffer.size + 1) - (bottom - top);
210 DEBUGV(
"bottom:%d top:%d timestamp:%lu\n", bottom, top, timestamp);
213 #endif //_RTEML_READER_H_ size_t length() const
Definition: reader.h:205
bool gap() const
Definition: reader.h:194
timeabs timespanw
Definition: time_compat.h:94
error_t pop(typename B::event_t &)
Definition: reader.h:150
B buffer_t
Definition: reader.h:62
#define DEBUGV3(...)
Definition: debug_compat.h:84
void debug() const
Definition: reader.h:209
#define DEBUGV(...)
Definition: debug_compat.h:83
timespanw timestamp
Definition: reader.h:59
bool synchronize()
Definition: reader.h:169
error_t
Definition: reader.h:64
error_t pull(typename B::event_t &)
Definition: reader.h:125
size_t bottom
Definition: reader.h:54
size_t top
Definition: reader.h:49
RTML_reader(const B &)
Definition: reader.h:120
const B & buffer
Definition: reader.h:44