Wait waits task for completion or wait timeout.
(ctx context.Context, id int64)
| 121 | |
| 122 | // Wait waits task for completion or wait timeout. |
| 123 | func (m *Manager) Wait(ctx context.Context, id int64) (err error) { |
| 124 | i := &waitItem{ |
| 125 | id: id, |
| 126 | ch: make(chan struct{}), |
| 127 | } |
| 128 | |
| 129 | m.waitCh <- i |
| 130 | |
| 131 | select { |
| 132 | case <-i.ch: |
| 133 | return |
| 134 | case <-ctx.Done(): |
| 135 | err = ctx.Err() |
| 136 | return |
| 137 | case <-m.ctx.Done(): |
| 138 | err = m.ctx.Err() |
| 139 | return |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | // New pushes new task to scheduling pool. |
| 144 | func (m *Manager) New(tt model.TaskType, developer int64, account int64, args gin.H) (id int64, err error) { |
no outgoing calls