Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LifeCycle ¶
type LifeCycle interface { // Start is idempotent // No action would be performed if Start is called twice without calling Stop // return false if already started Start() bool // Stop is idempotent // No action would be performed if Stop is called twice without calling Start // return false if already stopped Stop() bool // StopComplete should be called by user when the stop action terminates // (e.g. clean up is finished, all the goroutine has exited) // It would unblock Wait() StopComplete() // StopCh would broadcast the Stop message when Stop is called StopCh() <-chan struct{} // Wait() would block until StopComplete is called Wait() }
LifeCycle manages the lifecycle for the owner of the object example:
lifeCycle LifeCycle lifeCycle.Start() go func() { select { case <-lifeCycle.StopCh(): lifeCycle.StopComplete() return } }() lifeCycle.Stop() // block until the goroutine returns
Click to show internal directories.
Click to hide internal directories.