test.cpp/inc/ringbuffer.h

25 lines
387 B
C
Raw Normal View History

2019-10-30 10:41:30 +00:00
#ifndef __INC_RINGBUFFER_H__
#define __INC_RINGBUFFER_H__
#include <array>
class ringbuffer
{
public:
ringbuffer();
int write(char);
int read(char&);
private:
enum {
MAX_BUFFER_SIZE = 2
};
std::array<char, MAX_BUFFER_SIZE> buffer;
std::array<char, MAX_BUFFER_SIZE>::iterator head;
std::array<char, MAX_BUFFER_SIZE>::iterator tail;
};
#endif