lifecycle

package
v0.0.0-...-2ce8548 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2015 License: BSD-2-Clause Imports: 2 Imported by: 5

Documentation

Overview

Package lifecycle implements a simple helper object to make synchronization of worker goroutines a little less verbose.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lifecycle

type Lifecycle struct {
	// contains filtered or unexported fields
}

Lifecycle provides a simple way to coordinate the lifecycle of worker goroutines that loop infinitely

func New

func New() *Lifecycle

New is a helper function which creates a newly initialized Lifecycle object and returns a pointer to it for use.

func (*Lifecycle) QueryHeartbeat

func (this *Lifecycle) QueryHeartbeat() <-chan bool

QueryHeartbeat returns the read-only channel on which a user should listen for a periodic heartbeat signal.

func (*Lifecycle) QueryRun

func (this *Lifecycle) QueryRun() bool

QueryRun returns the current status of the Sync object. It will return true until Shutdown() is called. Client code can use this function as their criteria in a typical for-select work loop.

func (*Lifecycle) QueryShutdown

func (this *Lifecycle) QueryShutdown() <-chan bool

QueryShutdown returns the read-only channel on which a user should listen for a signal to shut down.

func (*Lifecycle) Shutdown

func (this *Lifecycle) Shutdown()

Shutdown sets the run flag to false, sends the shutdown signal back to the client on the shutdown channel, and then blocks until the client calls ShutdownComplete()

func (*Lifecycle) ShutdownComplete

func (this *Lifecycle) ShutdownComplete()

ShutdownComplete sends a signal which unblocks the call to Shutdown(). Client code should call this function once its shutdown procedures are completed.

func (*Lifecycle) StartHeart

func (this *Lifecycle) StartHeart(heartbeatMs int)

StartHeart sets the heartbeat cycle time in milliseconds and starts the heartbeat timer.

func (*Lifecycle) StopHeart

func (this *Lifecycle) StopHeart()

StopHeart sets the heartbeat cyle time to zero. If any timers are outstanding they will stil fire, but a signal will not be sent back to clients.

Jump to

Keyboard shortcuts

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