mirror of
https://github.com/asticode/go-astikit.git
synced 2025-12-24 11:50:53 +08:00
Now waiting for first level tasks to be done when using Task.Do()
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user