mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 12:42:34 +02:00
small fix on task.finish
This commit is contained in:
parent
4dda54c9e6
commit
846c1a104e
1 changed files with 3 additions and 8 deletions
|
@ -93,15 +93,10 @@ func (t *Task) onCancel(about string, fn func(), waitSubTasks bool) {
|
|||
// Finish cancel all subtasks and wait for them to finish,
|
||||
// then marks the task as finished, with the given reason (if any).
|
||||
func (t *Task) Finish(reason any) {
|
||||
select {
|
||||
case <-t.finished:
|
||||
return
|
||||
default:
|
||||
t.once.Do(func() {
|
||||
t.finish(reason)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Task) finish(reason any) {
|
||||
t.cancel(fmtCause(reason))
|
||||
|
|
Loading…
Add table
Reference in a new issue