tsuru: github.com/bardusco/tsuru/safe Index | Files

package safe

import "github.com/bardusco/tsuru/safe"

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


Package Files

buffer.go counter.go

type Buffer Uses

type Buffer struct {
    // contains filtered or unexported fields

Buffer is a thread safe version of bytes.Buffer.

func NewBuffer Uses

func NewBuffer(b []byte) *Buffer

func (*Buffer) Bytes Uses

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

func (*Buffer) Len Uses

func (sb *Buffer) Len() int

func (*Buffer) Next Uses

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

func (*Buffer) Read Uses

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

func (*Buffer) ReadByte Uses

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

func (*Buffer) ReadBytes Uses

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

func (*Buffer) ReadFrom Uses

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

func (*Buffer) ReadRune Uses

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

func (*Buffer) ReadString Uses

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

func (*Buffer) Reset Uses

func (sb *Buffer) Reset()

func (*Buffer) String Uses

func (sb *Buffer) String() string

func (*Buffer) Truncate Uses

func (sb *Buffer) Truncate(n int)

func (*Buffer) UnreadByte Uses

func (sb *Buffer) UnreadByte() error

func (*Buffer) UnreadRune Uses

func (sb *Buffer) UnreadRune() error

func (*Buffer) Write Uses

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

func (*Buffer) WriteByte Uses

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

func (*Buffer) WriteRune Uses

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

func (*Buffer) WriteTo Uses

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

type Counter Uses

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 Uses

func NewCounter(initial int64) *Counter

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

func (*Counter) Decrement Uses

func (c *Counter) Decrement()

Decrement decrements the value of c by 1.

func (*Counter) Increment Uses

func (c *Counter) Increment()

Increment increments the value of c by 1.

func (*Counter) Val Uses

func (c *Counter) Val() int64

Val returns the current value of the counter.

Package safe imports 4 packages (graph). Updated 2017-05-11. Refresh now. Tools for package owners.