wait

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NeverStop = context.TODO()
	NoThing   = func() { return }
)

Functions

func BackoffUntil

func BackoffUntil(ctx context.Context, f func(), backoff BackoffManager, sliding bool)

BackoffUntil 不断的运行 f 函数,运行间隔由BackoffManager 提供, 直到ctx.Done 返回. sliding 为true 则计算f函数运行时间.sliding 为false 则忽视f运行时间.

func Forever

func Forever(f func(), period time.Duration, sliding bool)

Forever 不断的以间隔period运行f. sliding 为true 则计算f函数运行时间.sliding 为false 则忽视f运行时间.

func NonSlidingUntil

func NonSlidingUntil(ctx context.Context, f func(), period time.Duration)

NonSlidingUntil 不断的以间隔period运行f, 直到ctx.Done 返回. 忽视f函数运行时间.

func Until

func Until(ctx context.Context, f func(), period time.Duration)

Until 不断的以间隔period运行f, 直到ctx.Done 返回. 间隔计算f函数运行时间.

Types

type BackoffManager

type BackoffManager interface {
	Backoff() *time.Timer
}

BackoffManager 接口可以提供 Backoff 方法, Backoff 返回一个Timer 确定要等待的时间

func NewSimpleBackoffManager

func NewSimpleBackoffManager(period time.Duration) BackoffManager

NewSimpleBackoffManager 返回一个简单的BackoffManager 以固定时间间隔返回Backoff

Jump to

Keyboard shortcuts

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