Ringbuffer

This commit is contained in:
Thomas Klaehn
2019-10-30 11:41:30 +01:00
parent 142e054efc
commit 828d55e708
5 changed files with 110 additions and 32 deletions

24
inc/ringbuffer.h Normal file
View File

@@ -0,0 +1,24 @@
#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