Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Nice ring buffer implementation! I like it and plan to use it with socket-IO in a stack. I had an issue with writing and reading sockets as they require continuous memory segments. So I implemented a sockets interface extension to the ring buffer that allows for efficient access to sockets from Ringbuffer without intermediate copying steps. The extension requires some additional methods within the class to get the length of continuous data in the data_buff member. The actual socket read and write functions are implemented outside class Ringbuffer. All added methods to Ringbuffer can be made protected (except print which is just a quick fix for testing) if the two external functions are made friends as they likely shouldn't be directly accessed from elsewhere. I haven't done that.
I'm not too good at atomics programming and there might be better methods to implement the socket interface which I'm not aware of. Anyway, this is a first shot and if you don't think this sockets API is too specialized and of good enough quality then I think it would be nice to have it integrated with Ringbuffer.
The test file shows how the interface is used. I have added dummy socket-IO functions with Posix interface for testing in a rudimentary test sequence.