Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyClosed = fmt.Errorf("Chan already closed")
Functions ¶
This section is empty.
Types ¶
type Halter ¶
type Halter struct { // The owning goutine should call Done.Close() as its last // action once it has received the ReqStop() signal. Done IdemCloseChan // Other goroutines call ReqStop.Close() in order // to request that the owning goroutine stop immediately. // The owning goroutine should select on ReqStop.Chan // in order to recognize shutdown requests. ReqStop IdemCloseChan }
Halter helps shutdown a goroutine
func (*Halter) IsStopRequested ¶
IsStopRequested returns true iff h.ReqStop has been Closed().
func (*Halter) MarkDone ¶
func (h *Halter) MarkDone()
MarkDone closes the h.Done channel if it has not already done so. Safe for multiple goroutine access.
func (*Halter) RequestStop ¶
func (h *Halter) RequestStop()
RequestStop closes the h.ReqStop channel if it has not already done so. Safe for multiple goroutine access.
type IdemCloseChan ¶
type IdemCloseChan struct { Chan chan struct{} // contains filtered or unexported fields }
IdemCloseChan can have Close() called on it multiple times, and it will only close Chan once.
func NewIdemCloseChan ¶
func NewIdemCloseChan() *IdemCloseChan
NewIdemCloseChan makes a new IdemCloseChan.
func (*IdemCloseChan) Close ¶
func (c *IdemCloseChan) Close() error
Close returns ErrAlreadyClosed if it has been called before. It never closes IdemClose.Chan more than once, so it is safe to ignore the returned error value. Close() is safe for concurrent access by multiple goroutines. Close returns nil on the initial call, and ErrAlreadyClosed on any subsequent call.
func (*IdemCloseChan) IsClosed ¶
func (c *IdemCloseChan) IsClosed() bool
IsClosed tells you if Chan is already closed or not.
func (*IdemCloseChan) Reinit ¶
func (c *IdemCloseChan) Reinit()
Reinit re-allocates the Chan, assinging a new channel and reseting the state as if brand new.