mirror of
https://github.com/safing/portbase
synced 2025-09-04 11:40:23 +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
|
t.executing = false
|
||||||
|
|
||||||
// repeat?
|
// repeat?
|
||||||
if t.isActive() && t.repeat != 0 {
|
if t.isActive() && t.repeat != 0 && t.executeAt.IsZero() {
|
||||||
t.executeAt = time.Now().Add(t.repeat)
|
t.executeAt = time.Now().Add(t.repeat)
|
||||||
t.addToSchedule(false)
|
t.addToSchedule(false)
|
||||||
}
|
}
|
||||||
|
@ -366,6 +366,9 @@ func (t *Task) executeWithLocking() {
|
||||||
t.lock.Unlock()
|
t.lock.Unlock()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
// reset executeAt to detect if task set next execution itself
|
||||||
|
t.executeAt = time.Time{}
|
||||||
|
|
||||||
// run
|
// run
|
||||||
err := t.taskFn(t.ctx, t)
|
err := t.taskFn(t.ctx, t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue