kubernetesk8s.io/kubernetes/contrib/mesos/pkg/runtime Index | Files

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

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

func Until(f func(), period time.Duration, stopCh <-chan struct{})

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

func (self *Latch) Acquire() bool

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 OnOSSignal(sig <-chan os.Signal, f func(os.Signal)) Signal

func (Signal) Then

func (sig Signal) Then(f func()) Signal

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.0
Published
Sep 25, 2015
Platform
js/wasm
Imports
6 packages
Last checked
18 seconds ago

Tools for package owners.