package runtime
import "k8s.io/kubernetes/contrib/mesos/pkg/runtime"
Package runtime provides utilities for semaphores (chan struct{}), a simple Latch implementation, and metrics for reporting handled panics.
Index ¶
- func Closer(sig chan<- struct{}) func()
- func Register()
- func Until(f func(), period time.Duration, stopCh <-chan struct{})
- type Latch
- type Signal
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
func Register ¶
func Register()
func Until ¶
periodically execute the given function, stopping once stopCh is closed. this func blocks until stopCh is closed, it's intended to be run as a goroutine.
Types ¶
type Latch ¶
type Latch struct {
// contains filtered or unexported fields
}
func (*Latch) Acquire ¶
return true if this latch was successfully acquired. concurrency safe. will only return true upon the first invocation, all subsequent invocations will return false. always returns false when self is nil.
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.
func On ¶
func On(sig <-chan struct{}, f func()) Signal
execute a callback function after the specified signal chan closes. immediately returns a signal that indicates f's completion.
func OnOSSignal ¶
func (Signal) Then ¶
upon receiving signal sig invoke function f and immediately return a signal that indicates f's completion. used to chain handler funcs, for example:
On(job.Done(), response.Send).Then(wg.Done)
Source Files ¶
doc.go latch.go metrics.go util.go
- Version
- v1.1.3
- Published
- Dec 7, 2015
- Platform
- js/wasm
- Imports
- 6 packages
- Last checked
- 8 seconds ago –
Tools for package owners.