github.com/masahide/goansible@v0.0.0-20160116054156-01eac649e9f2/async.go (about)

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