Documentation ¶
Overview ¶
Package runtime provides utilities for semaphores (chan struct{}), a simple Latch implementation, and metrics for reporting handled panics.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Closer ¶
func Closer(sig chan<- struct{}) func()
return a func that will close the signal chan. multiple invocations of the returned func will not generate a panic. two funcs from separate invocations of Closer() (on the same sig chan) will cause a panic if both invoked. for example:
// good x := runtime.After(func() { ... }) f := x.Closer() f() f() // bad x := runtime.After(func() { ... }) f := x.Closer() g := x.Closer() f() g() // this will panic
Types ¶
type Signal ¶
type Signal <-chan struct{}
func After ¶
func After(f func()) Signal
spawn a goroutine to execute a func, immediately returns a chan that closes upon completion of the func. returns a nil signal chan if the given func is nil.
Click to show internal directories.
Click to hide internal directories.