ptimer

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

定时器,为了方便后续统一维护和二次扩展,故此将所有的方法重新二次封装一遍

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultOptions

func DefaultOptions() gtimer.TimerOptions

DefaultOptions creates and returns a default options object for Timer creation.

func DelayAdd

func DelayAdd(ctx context.Context, delay time.Duration, interval time.Duration, job JobFunc)

DelayAdd adds a timing job after delay of `interval` duration. Also see Add.

func DelayAddEntry

func DelayAddEntry(ctx context.Context, delay time.Duration, interval time.Duration, job JobFunc, isSingleton bool, times int, status int)

DelayAddEntry adds a timing job after delay of `interval` duration. Also see AddEntry.

func DelayAddOnce

func DelayAddOnce(ctx context.Context, delay time.Duration, interval time.Duration, job JobFunc)

DelayAddOnce adds a timing job after delay of `interval` duration. Also see AddOnce.

func DelayAddSingleton

func DelayAddSingleton(ctx context.Context, delay time.Duration, interval time.Duration, job JobFunc)

DelayAddSingleton adds a timing job after delay of `interval` duration. Also see AddSingleton.

func DelayAddTimes

func DelayAddTimes(ctx context.Context, delay time.Duration, interval time.Duration, times int, job JobFunc)

DelayAddTimes adds a timing job after delay of `interval` duration. Also see AddTimes.

func SetInterval

func SetInterval(ctx context.Context, interval time.Duration, job JobFunc)

SetInterval runs the job every duration of `delay`. It is like the one in javascript.

func SetTimeout

func SetTimeout(ctx context.Context, delay time.Duration, job JobFunc)

SetTimeout runs the job once after duration of `delay`. It is like the one in javascript.

Types

type Entry

type Entry = *gtimer.Entry

Entry is the timing job.

func Add

func Add(ctx context.Context, interval time.Duration, job JobFunc) Entry

Add adds a timing job to the default timer, which runs in interval of `interval`.

func AddEntry

func AddEntry(ctx context.Context, interval time.Duration, job JobFunc, isSingleton bool, times int, status int) Entry

AddEntry adds a timing job to the default timer with detailed parameters.

The parameter `interval` specifies the running interval of the job.

The parameter `singleton` specifies whether the job running in singleton mode. There's only one of the same job is allowed running when its a singleton mode job.

The parameter `times` specifies limit for the job running times, which means the job exits if its run times exceeds the `times`.

The parameter `status` specifies the job status when it's firstly added to the timer.

func AddOnce

func AddOnce(ctx context.Context, interval time.Duration, job JobFunc) Entry

AddOnce is a convenience function for adding a job which only runs once and then exits.

func AddSingleton

func AddSingleton(ctx context.Context, interval time.Duration, job JobFunc) Entry

AddSingleton is a convenience function for add singleton mode job.

func AddTimes

func AddTimes(ctx context.Context, interval time.Duration, times int, job JobFunc) Entry

AddTimes is a convenience function for adding a job which is limited running times.

type JobFunc

type JobFunc = gtimer.JobFunc

JobFunc is the timing called job function in timer.

type Timer

type Timer = gtimer.Timer

Timer is the timer manager, which uses ticks to calculate the timing interval.

Jump to

Keyboard shortcuts

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