Documentation
¶
Overview ¶
定时任务 提供周期性任务执行功能。使用方式类似于Linux下的Crontab或者Java里的Quartz。本对象线程安全。
Package cable implements utility functions for scheduling/limiting function calls
定时任务 提供周期性任务执行功能。使用方式类似于Linux下的Crontab或者Java里的Quartz。本对象线程安全。
Index ¶
- func Debounce(f func(), interval time.Duration, options DebounceOptions) func()
- func E时钟_创建(fn func() bool, 时钟周期 int64)
- func E时钟_创建周期函数(fn func(), 时钟周期 int64) func()
- func E时钟_创建执行一次(fn func(), 时钟周期 int64)
- func SetInterval(f func() bool, interval time.Duration) func()
- func SetTimeout(f func(), interval time.Duration) func()
- func Throttle(f func(), interval time.Duration, options ThrottleOptions) func()
- type DebounceOptions
- type E时钟
- type ThrottleOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debounce ¶
func Debounce(f func(), interval time.Duration, options DebounceOptions) func()
Debounce returns a function that no matter how many times it is invoked, it will only execute after the specified interval has passed from its last invocation
func E时钟_创建执行一次 ¶
func E时钟_创建执行一次(fn func(), 时钟周期 int64)
func SetInterval ¶
SetInterval executes function f repeatedly with a fixed time delay(interval) between each call until function f returns false. It returns a cancel function which can be used to cancel aswell the execution of function f
func SetTimeout ¶
SetTimeout postpones the execution of function f for the specified interval. It returns a cancel function which when invoked earlier than the specified interval, it will cancel the execution of function f. Note that function f is executed in a different goroutine
func Throttle ¶
func Throttle(f func(), interval time.Duration, options ThrottleOptions) func()
Throttle returns a function that no matter how many times it is invoked, it will only execute once within the specified interval
Types ¶
type DebounceOptions ¶
type DebounceOptions struct {
Immediate bool
}
DebounceOptions is used to further configure the behavior of a debounced-function
type ThrottleOptions ¶
type ThrottleOptions struct {
Immediate bool
}
ThrottleOptions is used to further configure the behavior of a throttled-function