go_concurrency

package module
v0.1.0 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) GetAndOperateValue

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

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

func (*SafeNumber) GetValue

func (sn *SafeNumber) GetValue() int

GetValue returns the current value of the number

func (*SafeNumber) GetValueAndDecrement

func (sn *SafeNumber) GetValueAndDecrement() int

GetValueAndDecrement returns the current value of the number and decrements it by 1

func (*SafeNumber) GetValueAndIncrement

func (sn *SafeNumber) GetValueAndIncrement() int

GetValueAndIncrement returns the current value of the number and increments it by 1

func (*SafeNumber) Increment

func (sn *SafeNumber) Increment()

Increment increments the number by 1

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