MCPcopy
hub / github.com/jackc/pgx / Watch

Method Watch

pgconn/ctxwatch/context_watcher.go:32–47  ·  view source on GitHub ↗

Watch starts watching ctx. If ctx is canceled then the onCancel function passed to NewContextWatcher will be called.

(ctx context.Context)

Source from the content-addressed store, hash-verified

30
31// Watch starts watching ctx. If ctx is canceled then the onCancel function passed to NewContextWatcher will be called.
32func (cw *ContextWatcher) Watch(ctx context.Context) {
33 cw.lock.Lock()
34 defer cw.lock.Unlock()
35
36 if cw.stop != nil {
37 panic("watch already in progress")
38 }
39
40 if ctx.Done() != nil {
41 cw.done = make(chan struct{})
42 cw.stop = context.AfterFunc(ctx, func() {
43 cw.handler.HandleCancel(ctx)
44 close(cw.done)
45 })
46 }
47}
48
49// Unwatch stops watching the previously watched context. If the onCancel function passed to NewContextWatcher was
50// called then onUnwatchAfterCancel will also be called.

Calls 1

HandleCancelMethod · 0.65