pipe

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosedPipe = errors.New("pipe: write on closed pipe")

ErrClosedPipe will occur when manipulating an already closed pipe

Functions

func Pipe

func Pipe() (*Reader, *Writer)

Pipe creates a synchronous in-memory pipe.

It is safe to call Read and Write in parallel with each other or with Close. Parallel calls to Read and parallel calls to Write are also safe: the individual calls will be gated sequentially.

Types

type Reader

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

Reader reads real data

func (*Reader) Close

func (r *Reader) Close()

Close closes the reader; subsequent writes to the

func (*Reader) ReadAll

func (r *Reader) ReadAll() chan interface{}

ReadAll returns the data chan. The caller should use it as `for r := range pr.ReadAll()`

type Writer

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

Writer writes real data

func (*Writer) Close

func (w *Writer) Close()

Close closes the writer; subsequent ReadAll from the read half of the pipe will return a closed channel.

func (*Writer) Write

func (w *Writer) Write(item interface{}) error

Write writes the item to the underlying data stream. It returns ErrClosedPipe when the data stream is closed.

Jump to

Keyboard shortcuts

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