mirror of
https://github.com/safing/portbase
synced 2025-04-17 07:59:09 +00:00
Allow tasks to schedule themselves in-task
This commit is contained in:
parent
7797a54d18
commit
3f8f50ad1f
1 changed files with 4 additions and 1 deletions
|
@ -351,7 +351,7 @@ func (t *Task) executeWithLocking() {
|
|||
t.executing = false
|
||||
|
||||
// repeat?
|
||||
if t.isActive() && t.repeat != 0 {
|
||||
if t.isActive() && t.repeat != 0 && t.executeAt.IsZero() {
|
||||
t.executeAt = time.Now().Add(t.repeat)
|
||||
t.addToSchedule(false)
|
||||
}
|
||||
|
@ -366,6 +366,9 @@ func (t *Task) executeWithLocking() {
|
|||
t.lock.Unlock()
|
||||
}()
|
||||
|
||||
// reset executeAt to detect if task set next execution itself
|
||||
t.executeAt = time.Time{}
|
||||
|
||||
// run
|
||||
err := t.taskFn(t.ctx, t)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue