atomiccounter

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package atomiccounter provides the AtomicCounter type itself as well as functions and methods for interaction. The AtomicCounter type is a counter which uses atomic 64-bit integers to ensure thread-safety and high performance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomicCounter

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

AtomicCounter is a wrapper over an Atomic 64-bit Integer. This counter is thread-safe and mutex-free since it uses atomic operations.

func At

func At(i int64) *AtomicCounter

At function is like New, except that the counter will be set to the parameter of the function.

func New

func New() *AtomicCounter

New function will make a new Synced Counter, with its internal counter set to 0.

func (*AtomicCounter) Decrement

func (c *AtomicCounter) Decrement() int64

Decrement Method for decrementing the counter. It will return the new value of the counter.

func (*AtomicCounter) DecrementBy

func (c *AtomicCounter) DecrementBy(i int64) int64

DecrementBy for decrementing the counter by a set number. Just like Decrement, it will return the new value of the counter.

func (*AtomicCounter) Get

func (c *AtomicCounter) Get() int64

func (*AtomicCounter) Increment

func (c *AtomicCounter) Increment() int64

Increment method for incrementing the counter. It will return the new value which the counter holds.

func (*AtomicCounter) IncrementBy

func (c *AtomicCounter) IncrementBy(i int64) int64

IncrementBy method for incermenting the counter by a set number. Just like Increment, it will return the new value of the counter.

func (*AtomicCounter) Reset

func (c *AtomicCounter) Reset()

Reset Method for setting the counter back to 0.

Jump to

Keyboard shortcuts

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