safeCounter

package
v0.0.0-...-682d07f Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

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

Counter is a concurrency safe counter

func New

func New(maxcount int) *Counter

New returns a new concurrency safe hash map

func (*Counter) Add

func (m *Counter) Add(i int) bool

Add increases the count by i. it returns false if count < maxCount

func (*Counter) Dec

func (m *Counter) Dec()

Dec decrements the count by one.

func (*Counter) Inc

func (m *Counter) Inc() bool

Inc increases the count by one. it returns false if count < maxCount

func (*Counter) Info

func (m *Counter) Info() (int, int)

Info returns the current value of the counter and the maxCount

func (*Counter) IsFull

func (m *Counter) IsFull() bool

IsFull returns true if count is larger or equal to maxCount.

func (*Counter) String

func (m *Counter) String() string

func (*Counter) Sub

func (m *Counter) Sub(i int)

Sub decreases the count by i.

func (*Counter) Value

func (m *Counter) Value() int

Value 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