mixedbuffer

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

Buffer combines ring-buffer and list-buffer. Ring-buffer is the top-priority buffer to store response data, gnet will only switch to list-buffer if the data size of ring-buffer reaches the maximum(MaxStackingBytes), list-buffer is more flexible and scalable, which helps the application reduce memory footprint.

func New

func New(maxStaticBytes int) *Buffer

New instantiates a mixedbuffer.Buffer and returns it.

func (*Buffer) Discard

func (mb *Buffer) Discard(n int)

Discard discards n bytes in this buffer.

func (*Buffer) IsEmpty

func (mb *Buffer) IsEmpty() bool

IsEmpty indicates whether this buffer is empty.

func (*Buffer) Peek

func (mb *Buffer) Peek(n int) [][]byte

Peek returns n bytes as [][]byte, these bytes won't be discarded until Buffer.Discard() is called.

func (*Buffer) Release

func (mb *Buffer) Release()

Release frees all resource of this buffer.

func (*Buffer) Write

func (mb *Buffer) Write(p []byte) (n int, err error)

Write appends data to this buffer.

func (*Buffer) Writev

func (mb *Buffer) Writev(bs [][]byte) (int, error)

Writev appends multiple byte slices to this buffer.

Jump to

Keyboard shortcuts

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