Esempio n. 1
0
File: ring.go Progetto: fd/buffer
// NewRing returns a Ring Buffer from a BufferAt.
// It overwrites old data in the Buffer when needed (when its full).
func NewRing(buffer BufferAt) Buffer {
	return &ring{
		BufferAt:   buffer,
		WrapReader: wrapio.NewWrapReader(buffer, 0, buffer.Cap()),
		WrapWriter: wrapio.NewWrapWriter(buffer, 0, buffer.Cap()),
	}
}
Esempio n. 2
0
File: ring.go Progetto: fd/buffer
func (buf *ring) Reset() {
	buf.BufferAt.Reset()
	buf.L = 0
	buf.WrapReader = wrapio.NewWrapReader(buf.BufferAt, 0, buf.BufferAt.Cap())
	buf.WrapWriter = wrapio.NewWrapWriter(buf.BufferAt, 0, buf.BufferAt.Cap())
}