Documentation
¶
Overview ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AtomicRunState ¶
type AtomicRunState struct {
// contains filtered or unexported fields
}
AtomicRunState can be used to provide thread-safe start/stop functionality to internal run-loops inside a goroutine.
func (*AtomicRunState) IsRunning ¶
func (ars *AtomicRunState) IsRunning() bool
IsRunning returns true if the state is running or in the process of stopping.
func (*AtomicRunState) IsStopping ¶
func (ars *AtomicRunState) IsStopping() bool
IsStopping returns true if the run state has been stopped, but not yet reset.
func (*AtomicRunState) OnStop ¶
func (ars *AtomicRunState) OnStop() <-chan struct{}
OnStop returns a channel that should be used within a select goroutine run loop. It is set to signal whenever Stop() is executed. Once the channel is signaled, Reset() should be called if the runstate is to be used again.
func (*AtomicRunState) Reset ¶
func (ars *AtomicRunState) Reset()
Reset should be called in the select case for OnStop(). Note that calling Reset() prior to selecting OnStop() will result in failed Stop signal receive.
func (*AtomicRunState) Start ¶
func (ars *AtomicRunState) Start() bool
Start checks for an existing run state and returns false if the run state has already started. If the run state has not started, then it will advance to the started state and return true.
func (*AtomicRunState) Stop ¶
func (ars *AtomicRunState) Stop() bool
Stops closes the stop channel triggering any selects waiting for OnStop()
func (*AtomicRunState) WaitForReset ¶
func (ars *AtomicRunState) WaitForReset()
WaitForStop will wait for a stop to occur IFF the run state is in the process of stopping.