geteilterzaehler

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: MIT Imports: 3 Imported by: 0

README

High-performance universal counter, optimized for heavy concurrent use

Uses a racing shuttle, with user-injected extra entropy, to minimize the mutex contention of individual shards.

When used properly, it is usually N times faster than a simple mutex protected counter, where N is the number of real CPU cores, when using simple float64 counter. If the counting logic is more advanced, the gain can be more substantial.

Yields precise results, but doesn't guarantee specific time of measurement. See Heisenberg's indeterminacy principle, https://en.wikipedia.org/wiki/Uncertainty_principle.

References

Computer Networks Volume 244, May 2024, 110343 TbDd: A new trust-based, DRL-driven framework for blockchain sharding in IoT Zixu Zhang, Guangsheng Yu, Caijun Sun, Xu Wang, Ying Wang, Ming Zhang, Wei Ni, Ren Ping Liu, Andrew Reevesf, Nektarios Georgalasf

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Int

type Int struct {
	Breadth uint16
	// contains filtered or unexported fields
}

func NewInt

func NewInt(ff ...func(gz *Int)) (gz *Int)

func (*Int) ApplyValue

func (gz *Int) ApplyValue(extraEntropy uint16, f func(s *Scherbe))

func (*Int) BackgroundReducer

func (gz *Int) BackgroundReducer(ctx context.Context, tickPeriod time.Duration, batchPerTick int, f func(s *Scherbe, nextRound bool))

A backgroud goroutine for constant-rate reduction process

func (*Int) Reduce

func (gz *Int) Reduce(f func(s *Scherbe))

type Scherbe

type Scherbe struct {
	V float64
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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