28 lines
811 B
C
Raw Normal View History

2020-02-08 16:50:48 +01:00
#pragma once
#include <cstddef>
namespace tc {
class ring_buffer {
public:
/* Attention: Actual size may be larger than given capacity */
explicit ring_buffer(size_t /* minimum capacity */);
~ring_buffer();
[[nodiscard]] size_t capacity() const;
[[nodiscard]] size_t fill_count() const;
[[nodiscard]] size_t free_count() const;
/* do not write more than the capacity! */
char* write_ptr();
void advance_write_ptr(size_t /* count */);
/* do not read more than the capacity! */
[[nodiscard]] const void* read_ptr() const;
void advance_read_ptr(size_t /* count */);
void clear();
private:
void* handle{nullptr};
};
}