syncutil

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package syncutil provides concurrency utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtMost

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

AtMost executes a function at most once per the configured interval. Subsequent calls within the interval are silently skipped. Safe for concurrent use from multiple goroutines.

func NewAtMost

func NewAtMost(interval time.Duration) *AtMost

NewAtMost creates an AtMost that allows execution at most once per interval. The first call to Do always executes.

func (*AtMost) Do

func (a *AtMost) Do(fn func())

Do calls fn if at least interval has elapsed since the last successful invocation. Otherwise the call is silently skipped. The first call always executes because last is initialized to zero, which is treated as "never called".

Jump to

Keyboard shortcuts

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