Replace modulo op with compare/reset op

pull/7890/head
Deepika 2018-08-24 16:51:28 -05:00
parent 7c22dca302
commit 546743aeb0
1 changed files with 9 additions and 3 deletions

View File

@ -92,10 +92,14 @@ public:
core_util_critical_section_enter(); core_util_critical_section_enter();
if (full()) { if (full()) {
_tail++; _tail++;
_tail %= BufferSize; if(_tail == BufferSize) {
_tail = 0;
}
} }
_pool[_head++] = data; _pool[_head++] = data;
_head %= BufferSize; if(_head == BufferSize) {
_head = 0;
}
if (_head == _tail) { if (_head == _tail) {
_full = true; _full = true;
} }
@ -113,7 +117,9 @@ public:
core_util_critical_section_enter(); core_util_critical_section_enter();
if (!empty()) { if (!empty()) {
data = _pool[_tail++]; data = _pool[_tail++];
_tail %= BufferSize; if(_tail == BufferSize) {
_tail = 0;
}
_full = false; _full = false;
data_popped = true; data_popped = true;
} }