summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/done.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/internal/done.go b/internal/done.go
index 2326eee..54e5e8e 100644
--- a/internal/done.go
+++ b/internal/done.go
@@ -4,21 +4,25 @@ import (
"sync"
)
+// Done is a cleanup/shutdown helper.
type Done struct {
ch chan struct{}
mutex sync.Mutex
}
+// NewDone returns a new cleanup/shutdown helper.
func NewDone() *Done {
return &Done{
ch: make(chan struct{}),
}
}
+// Done returns the done channel (closed when done)
func (d *Done) Done() <-chan struct{} {
return d.ch
}
+// Shutdown closes the done channel. It can be called multiple times.
func (d *Done) Shutdown() {
d.mutex.Lock()
defer d.mutex.Unlock()