buffer

package
v0.0.0-...-29a4dac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2015 License: Apache-2.0, Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AlreadyClosed = errors.New("Buffer already closed")
)
View Source
var (
	FullError = errors.New("Buffer is full")
)

Functions

func BothClosed

func BothClosed(in *Inbound, out *Outbound) (closed bool)

Types

type Circular

type Circular struct {
	// contains filtered or unexported fields
}

A circular buffer on top of a byte-array NOTE: It does not implement the Write() method, it implements ReadFrom() to avoid copies

func NewCircular

func NewCircular(size int) *Circular

Returns a new circular buffer of the given size

func (*Circular) Read

func (c *Circular) Read(p []byte) (n int, err error)

Read data out of the buffer. This never fails but may return n==0 if there is no data to be read

func (*Circular) ReadFrom

func (c *Circular) ReadFrom(rd io.Reader) (n int, err error)

Copy data from the given reader into the buffer Any errors encountered while reading are returned EXCEPT io.EOF. If the reader fills the buffer, it returns buffer.FullError

type Inbound

type Inbound struct {
	*Circular
	*sync.Cond
	// contains filtered or unexported fields
}

func NewInbound

func NewInbound(size int) *Inbound

func (*Inbound) GetError

func (b *Inbound) GetError() (err error)

func (*Inbound) Read

func (b *Inbound) Read(p []byte) (n int, err error)

func (*Inbound) ReadFrom

func (b *Inbound) ReadFrom(rd io.Reader) (n int, err error)

func (*Inbound) SetDeadline

func (b *Inbound) SetDeadline(t time.Time)

func (*Inbound) SetError

func (b *Inbound) SetError(err error)

type Outbound

type Outbound struct {
	*sync.Cond
	// contains filtered or unexported fields
}

func NewOutbound

func NewOutbound(size int) *Outbound

func (*Outbound) Decrement

func (b *Outbound) Decrement(dec int) (ret int, err error)

func (*Outbound) Increment

func (b *Outbound) Increment(inc int)

func (*Outbound) SetError

func (b *Outbound) SetError(err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL