ringbuffer/ringbuffer.h

26 lines
482 B
C
Raw Normal View History

2023-04-08 22:35:17 +08:00
#ifndef RINGBUFFER_H
#define RINGBUFFER_H
#include <cstddef>
class Ringbuffer
{
public:
Ringbuffer();
Ringbuffer(size_t size);
~Ringbuffer();
size_t size() const;
size_t size_free();
size_t size_used();
size_t read(void *buf, size_t bufSize);
bool write(void *buf, size_t bufSize);
private:
size_t pSize;
unsigned char* headptr;
unsigned char* endptr;
unsigned char* readptr;
unsigned char* writeptr;
};
#endif // RINGBUFFER_H