ringbuffer: whitespace

This commit is contained in:
Ban Siesta
2015-05-24 10:01:28 +01:00
parent b9dc72f4cc
commit b9ce447cc9
2 changed files with 16 additions and 16 deletions
+15 -15
View File
@@ -57,25 +57,25 @@ RingBuffer::~RingBuffer()
unsigned unsigned
RingBuffer::_next(unsigned index) RingBuffer::_next(unsigned index)
{ {
return (0 == index) ? _num_items : (index - 1); return (0 == index) ? _num_items : (index - 1);
} }
bool bool
RingBuffer::empty() RingBuffer::empty()
{ {
return _tail == _head; return _tail == _head;
} }
bool bool
RingBuffer::full() RingBuffer::full()
{ {
return _next(_head) == _tail; return _next(_head) == _tail;
} }
unsigned unsigned
RingBuffer::size() RingBuffer::size()
{ {
return (_buf != nullptr) ? _num_items : 0; return (_buf != nullptr) ? _num_items : 0;
} }
void void
@@ -86,7 +86,7 @@ RingBuffer::flush()
} }
bool bool
RingBuffer::put(const void *val, size_t val_size) RingBuffer::put(const void *val, size_t val_size)
{ {
unsigned next = _next(_head); unsigned next = _next(_head);
if (next != _tail) { if (next != _tail) {
@@ -250,7 +250,7 @@ static inline bool my_sync_bool_compare_and_swap(volatile unsigned *a, unsigned
#define __PX4_SBCAP __sync_bool_compare_and_swap #define __PX4_SBCAP __sync_bool_compare_and_swap
#endif #endif
bool bool
RingBuffer::get(void *val, size_t val_size) RingBuffer::get(void *val, size_t val_size)
{ {
if (_tail != _head) { if (_tail != _head) {
unsigned candidate; unsigned candidate;
@@ -340,7 +340,7 @@ RingBuffer::get(double &val)
} }
unsigned unsigned
RingBuffer::space(void) RingBuffer::space(void)
{ {
unsigned tail, head; unsigned tail, head;
@@ -361,7 +361,7 @@ RingBuffer::space(void)
} }
unsigned unsigned
RingBuffer::count(void) RingBuffer::count(void)
{ {
/* /*
* Note that due to the conservative nature of space(), this may * Note that due to the conservative nature of space(), this may
@@ -371,7 +371,7 @@ RingBuffer::count(void)
} }
bool bool
RingBuffer::resize(unsigned new_size) RingBuffer::resize(unsigned new_size)
{ {
char *old_buffer; char *old_buffer;
char *new_buffer = new char [(new_size+1) * _item_size]; char *new_buffer = new char [(new_size+1) * _item_size];
@@ -388,13 +388,13 @@ RingBuffer::resize(unsigned new_size)
} }
void void
RingBuffer::print_info(const char *name) RingBuffer::print_info(const char *name)
{ {
printf("%s %u/%lu (%u/%u @ %p)\n", printf("%s %u/%lu (%u/%u @ %p)\n",
name, name,
_num_items, _num_items,
(unsigned long)_num_items * _item_size, (unsigned long)_num_items * _item_size,
_head, _head,
_tail, _tail,
_buf); _buf);
} }
+1 -1
View File
@@ -161,7 +161,7 @@ public:
private: private:
unsigned _num_items; unsigned _num_items;
const size_t _item_size; const size_t _item_size;
char *_buf; char *_buf;
volatile unsigned _head; /**< insertion point in _item_size units */ volatile unsigned _head; /**< insertion point in _item_size units */
volatile unsigned _tail; /**< removal point in _item_size units */ volatile unsigned _tail; /**< removal point in _item_size units */