Documentation
¶
Overview ¶
Package stopcontext extentds the standard Context interface with an additional Stopped signal, intended for gracefully stopping some iterative process associated with the Context.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Stopped ¶
Stopped is a helper function that calls Stopped if the given context has an ancestor created with WithStop from this package and Done otherwise.
It is useful for iterative processes that want to support both the standard Context and the graceful stop provided by this package's Context.
Types ¶
type Context ¶
type Context interface { context.Context // Stopped works similarly to Done, except it's also triggered by a call to // a StopFunc returned by WithStop. Stopped() <-chan struct{} // contains filtered or unexported methods }
Context wraps a context.Context. In addition to inheriting the wrapped context's Done signal, it has an additional Stopped signal that signals that some iterative process associated with the Context should stop on the next iteration, in a graceful manner.
Context cancellation also triggers the Stopped signal, so you don't need to attend to both.