Working with the RingBufferStream is the same as working with a MemoryStream and as such the most difficult part is remembering to Dispose the object once you're done with it.
Special mention needs to be given to the overloaded GetBuffer method:
- public IList<ArraySegment<byte>> GetBuffer(int count)
This method was added for retrieving the double buffer that can exist if the tail position wrapped around to the beginning of the underlying flat buffer and the head is not pointing to position zero.
The first element in the returned list will be the result of reading from the head position up to the end of the flat buffer and the second element will be the result of reading from the start of the flat buffer up to the tail position. If the tail hasn't wrapped then only one element will be returned, namely the result of reading from the head position up to the tail position.