mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #5058 from 0x6d61726b/patch-2
CircularBuffer(): get available transactionspull/5471/head
commit
589d76e59f
|
|
@ -109,6 +109,23 @@ public:
|
||||||
core_util_critical_section_exit();
|
core_util_critical_section_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get the number of elements currently stored in the circular_buffer */
|
||||||
|
CounterType size() const {
|
||||||
|
core_util_critical_section_enter();
|
||||||
|
CounterType elements;
|
||||||
|
if (!_full) {
|
||||||
|
if (_head < _tail) {
|
||||||
|
elements = BufferSize + _head - _tail;
|
||||||
|
} else {
|
||||||
|
elements = _head - _tail;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
elements = BufferSize;
|
||||||
|
}
|
||||||
|
core_util_critical_section_exit();
|
||||||
|
return elements;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T _pool[BufferSize];
|
T _pool[BufferSize];
|
||||||
volatile CounterType _head;
|
volatile CounterType _head;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue