safe

package
v0.0.0-...-1b7c243 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2017 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package safe provides some thread safe types, wrapping builtin types.

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 is a thread safe version of bytes.Buffer.

func NewBuffer

func NewBuffer(b []byte) *Buffer

func (*Buffer) Bytes

func (sb *Buffer) Bytes() []byte

func (*Buffer) Len

func (sb *Buffer) Len() int

func (*Buffer) Next

func (sb *Buffer) Next(n int) []byte

func (*Buffer) Read

func (sb *Buffer) Read(p []byte) (int, error)

func (*Buffer) ReadByte

func (sb *Buffer) ReadByte() (byte, error)

func (*Buffer) ReadBytes

func (sb *Buffer) ReadBytes(delim byte) ([]byte, error)

func (*Buffer) ReadFrom

func (sb *Buffer) ReadFrom(r io.Reader) (int64, error)

func (*Buffer) ReadRune

func (sb *Buffer) ReadRune() (rune, int, error)

func (*Buffer) ReadString

func (sb *Buffer) ReadString(delim byte) (string, error)

func (*Buffer) Reset

func (sb *Buffer) Reset()

func (*Buffer) String

func (sb *Buffer) String() string

func (*Buffer) Truncate

func (sb *Buffer) Truncate(n int)

func (*Buffer) UnreadByte

func (sb *Buffer) UnreadByte() error

func (*Buffer) UnreadRune

func (sb *Buffer) UnreadRune() error

func (*Buffer) Write

func (sb *Buffer) Write(p []byte) (int, error)

func (*Buffer) WriteByte

func (sb *Buffer) WriteByte(c byte) error

func (*Buffer) WriteRune

func (sb *Buffer) WriteRune(r rune) (int, error)

func (*Buffer) WriteString

func (sb *Buffer) WriteString(s string) (int, error)

func (*Buffer) WriteTo

func (sb *Buffer) WriteTo(w io.Writer) (int64, error)

type BytesReader

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

BytesReader is a thread safe version of bytes.Reader.

func NewBytesReader

func NewBytesReader(b []byte) *BytesReader

func (*BytesReader) Len

func (r *BytesReader) Len() int

func (*BytesReader) Read

func (r *BytesReader) Read(b []byte) (int, error)

func (*BytesReader) ReadAt

func (r *BytesReader) ReadAt(b []byte, off int64) (int, error)

func (*BytesReader) ReadByte

func (r *BytesReader) ReadByte() (byte, error)

func (*BytesReader) ReadRune

func (r *BytesReader) ReadRune() (rune, int, error)

func (*BytesReader) Seek

func (r *BytesReader) Seek(offset int64, whence int) (int64, error)

func (*BytesReader) UnreadByte

func (r *BytesReader) UnreadByte() error

func (*BytesReader) UnreadRune

func (r *BytesReader) UnreadRune() error

func (*BytesReader) WriteTo

func (r *BytesReader) WriteTo(w io.Writer) (int64, error)

type Counter

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

Counter implements a thread-safe, lock-free counter, that supports operations like increment and decrement.

It uses an int64 internally, so all int64 boundaries also apply here.

func NewCounter

func NewCounter(initial int64) *Counter

NewCounter creates a new counter with the given value as the initial value.

func (*Counter) Decrement

func (c *Counter) Decrement()

Decrement decrements the value of c by 1.

func (*Counter) Increment

func (c *Counter) Increment()

Increment increments the value of c by 1.

func (*Counter) Val

func (c *Counter) Val() int64

Val returns the current value of the counter.

Jump to

Keyboard shortcuts

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