We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 82f5b58 + 830db6a commit 589d76eCopy full SHA for 589d76e
platform/CircularBuffer.h
@@ -109,6 +109,23 @@ class CircularBuffer {
109
core_util_critical_section_exit();
110
}
111
112
+ /** Get the number of elements currently stored in the circular_buffer */
113
+ CounterType size() const {
114
+ core_util_critical_section_enter();
115
+ CounterType elements;
116
+ if (!_full) {
117
+ if (_head < _tail) {
118
+ elements = BufferSize + _head - _tail;
119
+ } else {
120
+ elements = _head - _tail;
121
+ }
122
123
+ elements = BufferSize;
124
125
+ core_util_critical_section_exit();
126
+ return elements;
127
128
+
129
private:
130
T _pool[BufferSize];
131
volatile CounterType _head;
0 commit comments