Skip to content

Commit

Permalink
fix issue #2355 (#2430)
Browse files Browse the repository at this point in the history
  • Loading branch information
gqcn authored Feb 8, 2023
1 parent 81d8aa5 commit a746794
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions os/gtimer/gtimer_timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/gogf/gf/v2/container/gtype"
)

// New creates and returns a Timer.
func New(options ...TimerOptions) *Timer {
t := &Timer{
queue: newPriorityQueue(),
Expand Down Expand Up @@ -98,39 +99,39 @@ func (t *Timer) AddTimes(ctx context.Context, interval time.Duration, times int,
})
}

// DelayAdd adds a timing job after delay of `interval` duration.
// DelayAdd adds a timing job after delay of `delay` duration.
// Also see Add.
func (t *Timer) DelayAdd(ctx context.Context, delay time.Duration, interval time.Duration, job JobFunc) {
t.AddOnce(ctx, delay, func(ctx context.Context) {
t.Add(ctx, interval, job)
})
}

// DelayAddEntry adds a timing job after delay of `interval` duration.
// DelayAddEntry adds a timing job after delay of `delay` duration.
// Also see AddEntry.
func (t *Timer) DelayAddEntry(ctx context.Context, delay time.Duration, interval time.Duration, job JobFunc, isSingleton bool, times int, status int) {
t.AddOnce(ctx, delay, func(ctx context.Context) {
t.AddEntry(ctx, interval, job, isSingleton, times, status)
})
}

// DelayAddSingleton adds a timing job after delay of `interval` duration.
// DelayAddSingleton adds a timing job after delay of `delay` duration.
// Also see AddSingleton.
func (t *Timer) DelayAddSingleton(ctx context.Context, delay time.Duration, interval time.Duration, job JobFunc) {
t.AddOnce(ctx, delay, func(ctx context.Context) {
t.AddSingleton(ctx, interval, job)
})
}

// DelayAddOnce adds a timing job after delay of `interval` duration.
// DelayAddOnce adds a timing job after delay of `delay` duration.
// Also see AddOnce.
func (t *Timer) DelayAddOnce(ctx context.Context, delay time.Duration, interval time.Duration, job JobFunc) {
t.AddOnce(ctx, delay, func(ctx context.Context) {
t.AddOnce(ctx, interval, job)
})
}

// DelayAddTimes adds a timing job after delay of `interval` duration.
// DelayAddTimes adds a timing job after delay of `delay` duration.
// Also see AddTimes.
func (t *Timer) DelayAddTimes(ctx context.Context, delay time.Duration, interval time.Duration, times int, job JobFunc) {
t.AddOnce(ctx, delay, func(ctx context.Context) {
Expand Down

0 comments on commit a746794

Please sign in to comment.