asyncbuf

package
v0.0.0-...-4816823 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: AGPL-3.0, Apache-2.0, CC-BY-SA-3.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 interface {
	io.WriteCloser

	// NewReader() returns an io.Reader that reads all data
	// written to the Buffer.
	NewReader() io.Reader

	// Close, but return the given error (instead of io.EOF) to
	// all readers when they reach the end of the buffer.
	//
	// CloseWithError(nil) is equivalent to
	// CloseWithError(io.EOF).
	CloseWithError(error) error
}

A Buffer is an io.Writer that distributes written data asynchronously to multiple concurrent readers.

NewReader() can be called at any time. In all cases, every returned io.Reader reads all data written to the Buffer.

Behavior is undefined if Write is called after Close or CloseWithError.

func NewBuffer

func NewBuffer(buf []byte) Buffer

NewBuffer creates a new Buffer using buf as its initial contents. The new Buffer takes ownership of buf, and the caller should not use buf after this call.

Source Files

  • buf.go

Jump to

Keyboard shortcuts

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