Enqueue enqueues the given Tasks "ts".
(ts ...Task)
| 148 | |
| 149 | // Enqueue enqueues the given Tasks "ts". |
| 150 | func (l *Logger) Enqueue(ts ...Task) { |
| 151 | if l == nil { |
| 152 | for _, t := range ts { |
| 153 | if t == nil { |
| 154 | // NOTE: Do not allow nil tasks which are unable |
| 155 | // to be completed. |
| 156 | continue |
| 157 | } |
| 158 | go func(t Task) { |
| 159 | for range t.Updates() { |
| 160 | // Discard all updates. |
| 161 | } |
| 162 | }(t) |
| 163 | } |
| 164 | return |
| 165 | } |
| 166 | |
| 167 | l.wg.Add(len(ts)) |
| 168 | for _, t := range ts { |
| 169 | if t == nil { |
| 170 | // NOTE: See above. |
| 171 | continue |
| 172 | } |
| 173 | l.queue <- t |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | // consume creates a pseudo-infinte buffer between the incoming set of tasks and |
| 178 | // the queue of tasks to work on. |