mirror of https://github.com/ARMmbed/mbed-os.git
CircularBuffer(): get available transactions
This implementation returns the number of available (stored) transactions in the bufferpull/5058/head
parent
e12f116ec1
commit
839cd7ee70
|
@ -105,6 +105,23 @@ public:
|
||||||
core_util_critical_section_exit();
|
core_util_critical_section_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns the number of available transactions the buffer contains */
|
||||||
|
CounterType available() {
|
||||||
|
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