util

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2020 License: Apache-2.0, MIT Imports: 1 Imported by: 1

Documentation

Overview

Package utils contains helper functions and structs used by dragonboat's examples.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUINT16

func GetUINT16(buf []byte) (n uint16)

func GetUINT32 added in v0.2.0

func GetUINT32(buf []byte) (n uint32)

func GetUINT40

func GetUINT40(buf []byte) uint64

func GetUINT64

func GetUINT64(buf []byte) (n uint64)

func Max added in v0.2.0

func Max(x uint64, y uint64) uint64

func Min

func Min(x uint64, y uint64) uint64

func Min32

func Min32(x uint32, y uint32) uint32

func PutUINT16

func PutUINT16(buf []byte, n uint16)

func PutUINT32 added in v0.2.0

func PutUINT32(buf []byte, n uint32)

func PutUINT40

func PutUINT40(buf []byte, val uint64)

func PutUINT64

func PutUINT64(buf []byte, n uint64)

Types

type Stopper

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

Stopper is a manager struct for managing worker goroutines.

func NewStopper

func NewStopper() *Stopper

NewStopper return a new Stopper instance.

func (*Stopper) Close

func (s *Stopper) Close()

Close closes the internal shouldStopc chan struct{} to signal all worker goroutines that they should stop.

func (*Stopper) RunWorker

func (s *Stopper) RunWorker(f func())

RunWorker creates a new goroutine and invoke the f func in that new worker goroutine.

func (*Stopper) ShouldStop

func (s *Stopper) ShouldStop() chan struct{}

ShouldStop returns a chan struct{} used for indicating whether the Stop() function has been called on Stopper.

func (*Stopper) Stop

func (s *Stopper) Stop()

Stop signals all managed worker goroutines to stop and wait for them to actually stop.

func (*Stopper) Wait

func (s *Stopper) Wait()

Wait waits on the internal sync.WaitGroup. It only return when all managed worker goroutines are ready to return and called sync.WaitGroup.Done() on the internal sync.WaitGroup.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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