counters

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StrictMonotonousCounter

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

StrictMonotonousCounter is a helper struct which implements a strict monotonous counter. StrictMonotonousCounter is implemented using atomic operations and doesn't allow to set a value which is lower or equal to the already stored one. The counter is implemented solely with non-blocking atomic operations for concurrency safety.

func NewMonotonousCounter

func NewMonotonousCounter(initialValue uint64) StrictMonotonousCounter

NewMonotonousCounter creates new counter with initial value

func (*StrictMonotonousCounter) Set

func (c *StrictMonotonousCounter) Set(newValue uint64) bool

Set updates value of counter if and only if it's strictly larger than value which is already stored. Returns true if update was successful or false if stored value is larger.

func (*StrictMonotonousCounter) Value

func (c *StrictMonotonousCounter) Value() uint64

Value returns value which is stored in atomic variable

Jump to

Keyboard shortcuts

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