plug

package
v1.2.0-rc2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2016 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Leased added in v1.0.5

type Leased struct {
	Plug
	// contains filtered or unexported fields
}

leased uses a Leaser to control Start and Stop on a Plug

func NewLeased added in v1.0.5

func NewLeased(leaser Leaser) *Leased

NewLeased creates a Plug that starts when a lease is acquired and stops when it is lost.

func (*Leased) Run added in v1.0.5

func (l *Leased) Run()

Run tries to acquire and hold a lease, invoking Start() when the lease is held and invoking Stop() when the lease is lost.

func (*Leased) Stop added in v1.0.5

func (l *Leased) Stop()

Stop releases the acquired lease

type Leaser added in v1.0.5

type Leaser interface {
	// AcquireAndHold tries to acquire the lease and hold it until it expires, the lease is deleted,
	// or we observe another party take the lease. The notify channel will be sent a value
	// when the lease is held, and closed when the lease is lost.
	AcquireAndHold(chan struct{})
	Release()
}

Leaser controls access to a lease

type Plug

type Plug interface {
	// Begins operation of the plug and unblocks WaitForStart().
	// May be invoked multiple times but only the first invocation has
	// an effect.
	Start()
	// Ends operation of the plug and unblocks WaitForStop()
	// May be invoked multiple times but only the first invocation has
	// an effect. Calling Stop() before Start() is undefined.
	Stop()
	// Blocks until Start() is invoked
	WaitForStart()
	// Blocks until Stop() is invoked
	WaitForStop()
	// Returns true if Start() has been invoked
	IsStarted() bool
}

Plug represents a synchronization primitive that holds and releases execution for other objects.

func New added in v1.0.5

func New(started bool) Plug

New returns a new plug that can begin in the Started state.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL