New creates and starts a new task loop.
(onClose func())
| 33 | |
| 34 | // New creates and starts a new task loop. |
| 35 | func New(onClose func()) *Loop { |
| 36 | l := &Loop{ |
| 37 | tasks: make(chan task), |
| 38 | done: make(chan struct{}), |
| 39 | taskLoopDone: make(chan struct{}), |
| 40 | } |
| 41 | |
| 42 | go l.runLoop(onClose) |
| 43 | |
| 44 | return l |
| 45 | } |
| 46 | |
| 47 | // runLoop handles registered tasks and agent close. |
| 48 | func (l *Loop) runLoop(onClose func()) { |