counter

package
v0.16.0-rc Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: Apache-2.0 Imports: 5 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
}

func NewCounter added in v0.10.0

func NewCounter(initialValue uint64) Counter

NewCounter creates a new counter with the given initial value.

func (*Counter) Decrease

func (c *Counter) Decrease(values ...uint64) error

Decrease decreases the counter by the given value (thread-safe).

func (*Counter) DecreaseAndRead

func (c *Counter) DecreaseAndRead(values ...uint64) (uint64, error)

DecreaseAndRead decreases the counter by the given value (thread-safe) and returns the new value.

func (*Counter) Format added in v0.10.0

func (c *Counter) Format(f fmt.State, r rune)

Format implements fmt.Formatter (thread-safe).

func (*Counter) Increase

func (c *Counter) Increase(values ...uint64) error

Increase increases the counter by the given value (thread-safe).

func (*Counter) IncreaseAndRead

func (c *Counter) IncreaseAndRead(values ...uint64) (uint64, error)

IncreaseAndRead increases the counter by the given value (thread-safe) and returns the new value.

func (*Counter) Read

func (c *Counter) Read() uint64

Read returns the current value of the counter (thread-safe).

func (*Counter) Set added in v0.10.0

func (c *Counter) Set(value uint64)

Set sets the counter to the given value (thread-safe).

Jump to

Keyboard shortcuts

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