github.com/vektra/tachyon@v0.0.0-20150921164542-0da4f3861aef/async.go (about) 1 package tachyon 2 3 type AsyncAction struct { 4 Task *Task 5 Error error 6 Result *Result 7 status chan *AsyncAction 8 } 9 10 func (a *AsyncAction) Init(r *Runner) { 11 r.wait.Add(1) 12 a.status = r.AsyncChannel() 13 } 14 15 func (a *AsyncAction) Finish(res *Result, err error) { 16 a.Error = err 17 a.Result = res 18 a.status <- a 19 } 20 21 func (r *Runner) handleAsync() { 22 for { 23 act := <-r.async 24 25 r.env.report.FinishAsyncTask(act) 26 27 if act.Error == nil { 28 for _, x := range act.Task.Notify() { 29 r.AddNotify(x) 30 } 31 } 32 33 r.wait.Done() 34 } 35 }