Now waiting for first level tasks to be done when using Task.Do()

This commit is contained in:
Quentin Renard
2020-11-13 18:06:13 +01:00
parent 8b50f3103e
commit d700e048b8

View File

@@ -126,6 +126,10 @@ func (t *Task) Do(f func()) {
// Custom
f()
// Wait for first level subtasks to be done
// Wait() can also be called in f() if something needs to be executed just after Wait()
t.Wait()
}()
}
@@ -136,7 +140,7 @@ func (t *Task) Done() {
})
}
// Wait waits for the task to be finished
// Wait waits for first level subtasks to be finished
func (t *Task) Wait() {
t.ow.Do(func() {
t.wg.Wait()