mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 20:52:33 +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,14 +93,9 @@ func (t *Task) onCancel(about string, fn func(), waitSubTasks bool) {
|
||||||
// Finish cancel all subtasks and wait for them to finish,
|
// Finish cancel all subtasks and wait for them to finish,
|
||||||
// then marks the task as finished, with the given reason (if any).
|
// then marks the task as finished, with the given reason (if any).
|
||||||
func (t *Task) Finish(reason any) {
|
func (t *Task) Finish(reason any) {
|
||||||
select {
|
t.once.Do(func() {
|
||||||
case <-t.finished:
|
t.finish(reason)
|
||||||
return
|
})
|
||||||
default:
|
|
||||||
t.once.Do(func() {
|
|
||||||
t.finish(reason)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) finish(reason any) {
|
func (t *Task) finish(reason any) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue