Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LogBuffer
- {
- public:
- bool is_empty() const { return head_ == tail_; }
- bool is_full() const { return uint16_t(tail_ + 1) == head_; }
- LogLine& head() { return log_buffer_[head_]; }
- LogLine& tail() { return log_buffer_[tail_]; }
- void advance_head() { ++head_; }
- void advance_hail() { ++tail_; }
- private:
- volatile uint16_t tail_ = 0; // write position
- LogLine log_buffer_[0xffff + 1]; // relies on the uint16_t overflowing
- volatile uint16_t head_ = 0; // read position
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement