Documentation
¶
Overview ¶
Package xcontext provides utilities for working with contexts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type StopFunc ¶
type StopFunc func()
A StopFunc tells an operation to stop after its completed its current unit of work. It is used to implement graceful shutdown semantics.
Contrast to context.CancelFunc which is is typically used to implement "forceful" cancellation semantics.
It does not wait for the work to stop. It may be called by multiple goroutines simultaneously. After the first call, subsequent calls do nothing.
func WithStop ¶
WithStop returns a derived context that points to the parent context but has a new Stopped channel.
The returned context's Stopped channel is closed when the returned stop function is called or when the parent context's Stopped channel is closed, whichever happens first.
Canceling the parent context not close the returned context's Stopped channel.