package ctxwatch
Import Path
github.com/jackc/pgconn/internal/ctxwatch (on go.dev)
Dependency Relation
imports one package, and imported by one package
Involved Source Files
context_watcher.go
Package-Level Type Names (only one, which is exported)
ContextWatcher watches a context and performs an action when the context is canceled. It can watch one context at a
time.
onCancel func()
onCancelWasCalled bool
onUnwatchAfterCancel func()
unwatchChan chan struct{}
watchInProgress bool
Unwatch stops watching the previously watched context. If the onCancel function passed to NewContextWatcher was
called then onUnwatchAfterCancel will also be called.
Watch starts watching ctx. If ctx is canceled then the onCancel function passed to NewContextWatcher will be called.
func NewContextWatcher(onCancel func(), onUnwatchAfterCancel func()) *ContextWatcher
Package-Level Functions (only one, which is exported)
NewContextWatcher returns a ContextWatcher. onCancel will be called when a watched context is canceled.
OnUnwatchAfterCancel will be called when Unwatch is called and the watched context had already been canceled and
onCancel called.
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |