Documentation
¶
Overview ¶
Package lifecycle provides a concurrency-safe close guard that tracks whether a resource has been closed and signals waiters via a channel.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrAlreadyClosed = errors.New("lifecycle: already closed")
ErrAlreadyClosed is returned by Guard.Close when the guard is already closed.
Functions ¶
This section is empty.
Types ¶
type Guard ¶
type Guard struct {
// contains filtered or unexported fields
}
Guard is a concurrency-safe close guard. It tracks whether Close has been called and provides a Done channel for goroutines to wait on.
func (*Guard) Close ¶
Close marks the guard as closed and closes the Done channel. Returns ErrAlreadyClosed if called more than once.
func (*Guard) Done ¶
func (g *Guard) Done() <-chan struct{}
Done returns a channel that is closed when Guard.Close is called. Callers can use this with select to detect shutdown.
Click to show internal directories.
Click to hide internal directories.