go_concurrency

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: GPL-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 SafeNumber

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

SafeNumber is a concurrent-safe number

func NewSafeNumber

func NewSafeNumber(initialValue int) *SafeNumber

NewSafeNumber creates a new SafeNumber

func (*SafeNumber) Decrement

func (sn *SafeNumber) Decrement()

Decrement decrements the number by 1

func (*SafeNumber) DecrementAndGetValue added in v0.1.1

func (sn *SafeNumber) DecrementAndGetValue() int

DecrementAndGetValue decrements the number by 1 and returns the new value

func (*SafeNumber) GetValue

func (sn *SafeNumber) GetValue() int

GetValue returns the current value of the number

func (*SafeNumber) Increment

func (sn *SafeNumber) Increment()

Increment increments the number by 1

func (*SafeNumber) IncrementAndGetValue added in v0.1.1

func (sn *SafeNumber) IncrementAndGetValue() int

IncrementAndGetValue increments the number by 1 and returns the new value

func (*SafeNumber) OperateAndGetValue added in v0.1.1

func (sn *SafeNumber) OperateAndGetValue(operation func(int) int) int

OperateAndGetValue performs an operation on the value of the number and returns the result

func (*SafeNumber) OperateValue

func (sn *SafeNumber) OperateValue(operation func(int) int)

OperateValue performs an operation on the value of the number

func (*SafeNumber) ResetValue

func (sn *SafeNumber) ResetValue()

ResetValue resets the value of the number to the initial value

Jump to

Keyboard shortcuts

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