utils

package
v0.0.0-...-f10b52b Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoFlushBufferWriter

type AutoFlushBufferWriter struct {
	*bufio.Writer
	// contains filtered or unexported fields
}

AutoFlushBufferWriter auto flush buffer writer

func NewAutoFlushBufferWriter

func NewAutoFlushBufferWriter(w *bufio.Writer, period time.Duration) *AutoFlushBufferWriter

NewAutoFlushBufferWriter create an AutoFlushBufferWriter with default flush period

func NewAutoFlushBufferWriterWithPeriod

func NewAutoFlushBufferWriterWithPeriod(w *bufio.Writer, period time.Duration) *AutoFlushBufferWriter

NewAutoFlushBufferWriterWithPeriod create an AutoFlushBufferWriter with flush period

func (*AutoFlushBufferWriter) Write

func (w *AutoFlushBufferWriter) Write(p []byte) (n int, err error)

type RecyclableIDGenerator

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

RecyclableIDGenerator generate recyclable unique ids.

func NewRecyclableIDGenerator

func NewRecyclableIDGenerator() *RecyclableIDGenerator

NewRecyclableIDGenerator create an id generator

func (*RecyclableIDGenerator) NextID

func (g *RecyclableIDGenerator) NextID() (id uint32)

NextID get the next id

func (*RecyclableIDGenerator) Recycle

func (g *RecyclableIDGenerator) Recycle(id uint32)

Recycle recyle the id for future use.

type Timer

type Timer struct {
	C <-chan time.Time
	// contains filtered or unexported fields
}

Timer wraps the time.Timer

func NewTimer

func NewTimer() *Timer

NewTimer create a timer

func NewTimerWithDuration

func NewTimerWithDuration(d time.Duration) *Timer

NewTimerWithDuration create a timer with duration

func (*Timer) Reset

func (t *Timer) Reset(d time.Duration)

Reset reset the timer to next duration

func (*Timer) Stop

func (t *Timer) Stop()

Stop prevents the Timer from firing.

Jump to

Keyboard shortcuts

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