mbed library sources, mbed-dev only for TYBLE16
Fork of mbed-dev by
Please refer flowing link.
/users/kenjiArai/notebook/tyble16-module-will-become-a-mbed-family--mbedliza/
Diff: platform/CircularBuffer.h
- Revision:
- 180:96ed750bd169
- Parent:
- 178:79309dc6340a
--- a/platform/CircularBuffer.h Thu Dec 07 14:01:42 2017 +0000 +++ b/platform/CircularBuffer.h Wed Jan 17 15:23:54 2018 +0000 @@ -109,6 +109,23 @@ 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: T _pool[BufferSize]; volatile CounterType _head;