Unwatch stops watching the previously watched context. If the onCancel function passed to NewContextWatcher was called then onUnwatchAfterCancel will also be called.
()
| 49 | // Unwatch stops watching the previously watched context. If the onCancel function passed to NewContextWatcher was |
| 50 | // called then onUnwatchAfterCancel will also be called. |
| 51 | func (cw *ContextWatcher) Unwatch() { |
| 52 | cw.lock.Lock() |
| 53 | defer cw.lock.Unlock() |
| 54 | |
| 55 | if cw.stop != nil { |
| 56 | if !cw.stop() { |
| 57 | <-cw.done |
| 58 | cw.handler.HandleUnwatchAfterCancel() |
| 59 | } |
| 60 | cw.stop = nil |
| 61 | cw.done = nil |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | type Handler interface { |
| 66 | // HandleCancel is called when the context that a ContextWatcher is currently watching is canceled. canceledCtx is the |