Skip to content

Latest commit

 

History

History
44 lines (32 loc) · 1 KB

README.md

File metadata and controls

44 lines (32 loc) · 1 KB

Build Status

ringbuffer

Simple RingBuffer pacakge Ringbuffer is non blocking for readers and writers, writers will overwrite older data in a circular fashion. Readers will read from the current position and update it.

Usage

type RingBuffer

type RingBuffer struct {
	Size      int           // Size of the Ringbuffer
	Container []interface{} // Array container of objects
	Reader    int           // Reader position
	Writer    int           // Writer Position
}

RingBuffer Structure

func NewRingBuffer

func NewRingBuffer(size int) *RingBuffer

Create a new RingBuffer of initial size "size" Returns a pointer to the new RingBuffer

func (*RingBuffer) Read

func (r *RingBuffer) Read() interface{}

Read single object from the RingBuffer

func (*RingBuffer) Write

func (r *RingBuffer) Write(v interface{})

Write object into the RingBuffer