test.cpp/inc/ringbuffer.h
Thomas Klaehn 828d55e708 Ringbuffer
2019-10-30 11:41:30 +01:00

25 lines
387 B
C++

#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