mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
Diff: platform/CircularBuffer.h
- Revision:
- 188:bcfe06ba3d64
- Parent:
- 187:0387e8f68319
- Child:
- 189:f392fc9709a3
--- a/platform/CircularBuffer.h Thu Sep 06 13:40:20 2018 +0100 +++ b/platform/CircularBuffer.h Thu Nov 08 11:46:34 2018 +0000 @@ -92,10 +92,14 @@ core_util_critical_section_enter(); if (full()) { _tail++; - _tail %= BufferSize; + if (_tail == BufferSize) { + _tail = 0; + } } _pool[_head++] = data; - _head %= BufferSize; + if (_head == BufferSize) { + _head = 0; + } if (_head == _tail) { _full = true; } @@ -113,7 +117,9 @@ core_util_critical_section_enter(); if (!empty()) { data = _pool[_tail++]; - _tail %= BufferSize; + if (_tail == BufferSize) { + _tail = 0; + } _full = false; data_popped = true; } @@ -194,9 +200,9 @@ private: T _pool[BufferSize]; - volatile CounterType _head; - volatile CounterType _tail; - volatile bool _full; + CounterType _head; + CounterType _tail; + bool _full; }; /**@}*/