Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrDying is returned when some action was cancelled due // to the Dying channel closing ErrDying = errors.New("killable: dying") // ErrKill is returned from managed goroutines to // put the Killable into the dying state ErrKill = errors.New("killable: killed") // ErrKillLocal is returned from managed goroutines to // put the killable into the dying state but without // propagating it to parent Killables ErrKillLocal = errors.New("killable: local killed") // ErrStillAlive is returned by Err if the Killable isn't dying ErrStillAlive = errors.New("killable: still alive") )
Functions ¶
func Defer ¶
func Defer(k Killable, fn func())
Defer invokes a callback once a Killable is dead. deferred functions will execute in the opposite order they were defined in if the Killable is already dead, the deferred will be called immediatly
func Do ¶
Do executes a function and retuns its error value. * If the Killable is marked as dying it will return immediatly with ErrDying. * The Killable will not be marked as dead until all calls to Do have returned.
func Go ¶
Go executes a function in a goroutine * If the function returns a non-nil error the Killable is killed using that error * The Killable will no be marked as dead until all calls to Go have returned
Types ¶
type Killable ¶
type Killable interface { // Dying is closed immediatly after Kill is called Dying() <-chan struct{} // Dead is closed after all executing functions have returned // These executing functions must have been started with Do or Go Dead() <-chan struct{} // Put the Killable into the dying state Kill(reason error) // Return the error passed to Kill // blocks until in dying state Err() error // Context returns a context.Context that's linked to the killable Context() context.Context // contains filtered or unexported methods }
Click to show internal directories.
Click to hide internal directories.