bsbuffer

package module
v0.0.0-...-94e85ab Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2018 License: LGPL-3.0 Imports: 4 Imported by: 5

README

bsbuffer

import "github.com/SergeyFrolov/bsbuffer"

Overview

Imported Packages

No packages beyond the Go standard library are imported.

Index

Package files

bsbuffer.go

type BSBuffer

type BSBuffer struct {
    sync.Mutex
    // contains filtered or unexported fields
}

BSBuffer: B - Blocking - Read() calls are blocking. S - Safe - Supports arbitrary amount of readers and writers. Could be unblocked and turned into SBuffer.

func NewBSBuffer
func NewBSBuffer() *BSBuffer

Creates new BSBuffer

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

Reads data from the BSBuffer, blocking until a writer arrives or the BSBuffer is unblocked. If the write end is closed with an error, that error is returned as err; otherwise err is EOF. Supports multiple concurrent goroutines and p is valid forever.

func (*BSBuffer) Unblock
func (b *BSBuffer) Unblock()

Turns BSBuffer into SBuffer: Read() is no longer blocking, but still safe. Unblock() is safe to call multiple times.

func (*BSBuffer) Write
func (b *BSBuffer) Write(p []byte) (n int, err error)

Non-blocking write appends the contents of p to the buffer, growing the buffer as needed. The return value n is the length of p; err is always nil. If the buffer becomes too large, Write will panic with ErrTooLarge. Supports multiple concurrent goroutines and p is safe for reuse right away.


Generated by godoc2ghmd

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BSBuffer

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

BSBuffer: B - Blocking - Read() calls are blocking. S - Safe - Supports arbitrary amount of readers and writers. Could be unblocked and turned into SBuffer.

func NewBSBuffer

func NewBSBuffer() *BSBuffer

Creates new BSBuffer

func (*BSBuffer) Read

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

Reads data from the BSBuffer, blocking until a writer arrives or the BSBuffer is unblocked. If the write end is closed with an error, that error is returned as err; otherwise err is EOF. Supports multiple concurrent goroutines and p is valid forever.

func (*BSBuffer) Unblock

func (b *BSBuffer) Unblock()

Turns BSBuffer into SBuffer: Read() is no longer blocking, but still safe. Unblock() is safe to call multiple times.

func (*BSBuffer) Write

func (b *BSBuffer) Write(p []byte) (n int, err error)

Non-blocking write appends the contents of p to the buffer, growing the buffer as needed. The return value n is the length of p; err is always nil. If the buffer becomes too large, Write will panic with ErrTooLarge. Supports multiple concurrent goroutines and p is safe for reuse right away.

Jump to

Keyboard shortcuts

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