zcwaiter

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Waiter

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

Waiter 等待器

func NewCustomWaiter

func NewCustomWaiter(waitMaxTimes int, waitMSPerTime time.Duration) (*Waiter, error)

NewCustomWaiter 创建等待器,采用指定的waitMaxTimes与waitMSPerTime

waitMaxTimes: 最大等待次数,必须大于0
waitMSPerTime: 每次等待时间(毫秒),必须大于0

func NewWaiter

func NewWaiter() *Waiter

NewWaiter 创建等待器,采用默认的waitMaxTimes与waitMSPerTime

waitMaxTimes: 最大等待次数,默认300
waitMSPerTime: 每次等待时间(毫秒),默认1000

func (*Waiter) WaitUntil

func (w *Waiter) WaitUntil(supplier func() bool) error

WaitUntil 让当前goroutine等待,直到传入的supplier函数返回true,或者超时。

@param supplier 等待终止函数
该函数会不断尝试调用supplier函数,直到其返回值为true;
但最多只会调用`Waiter.waitMaxTimes`次;
两次调用supplier函数之间的间隔时间为`Waiter.waitMSPerTime`。

Jump to

Keyboard shortcuts

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