routine

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecRoutineWithInterval

func ExecRoutineWithInterval(
	name string,
	routine RoutineFn,
	interval time.Duration,
)

定期执行工作例程

func StartWorkingRoutine

func StartWorkingRoutine(workers []WorkingRoutine) error

启动所有的工作例程

Types

type CountLimiter

type CountLimiter struct {
	UpperLimit uint32 // the upper limit
	// contains filtered or unexported fields
}

count limiter

func (*CountLimiter) Count

func (limit *CountLimiter) Count() uint32

return the current count

func (*CountLimiter) Decr

func (limit *CountLimiter) Decr()

decr the count

func (*CountLimiter) Incr

func (limit *CountLimiter) Incr()

incr the count

func (*CountLimiter) IncrIfNotFull

func (limit *CountLimiter) IncrIfNotFull() bool

if the count don't exceed the upper limit, incr the count return if incr the count

func (*CountLimiter) IsFull

func (limit *CountLimiter) IsFull() bool

check if the count exceeds the upper limit

type RoutineFn

type RoutineFn func()

例程类型

func WorkingRoutineWrapper

func WorkingRoutineWrapper(name string, fn RoutineFn, interval time.Duration) RoutineFn

工作例程包装函数

type WorkingRoutine

type WorkingRoutine struct {
	RoutineFn    RoutineFn     // 工作例程函数
	RoutineCount uint          // 例程数量
	Interval     time.Duration // 工作例程的执行间隔
}

工作例程结构

Jump to

Keyboard shortcuts

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