()
| 261 | } |
| 262 | |
| 263 | func (n *Nylon) Stop() { |
| 264 | n.cleanupOnce.Do(func() { |
| 265 | n.Cancel(context.Canceled) |
| 266 | if n.Context.Err() == nil { |
| 267 | select { |
| 268 | case n.DispatchChannel <- nil: // instead of close(), which can cause a data race |
| 269 | case <-n.Context.Done(): |
| 270 | } |
| 271 | } |
| 272 | }) |
| 273 | } |
| 274 | |
| 275 | func (n *Nylon) mainLoop() error { |
| 276 | n.Log.Debug("started main loop") |