Files
akvorado/common/daemon/lifecycle.go
Vincent Bernat 8be1bca4fd license: AGPL-3.0-only
```
git ls-files \*.js \*.go \
  | xargs sed -i '1i // SPDX-FileCopyrightText: 2022 Free Mobile\n// SPDX-License-Identifier: AGPL-3.0-only\n'
git ls-files \*.vue \
  | xargs sed -i '1i <!-- SPDX-FileCopyrightText: 2022 Free Mobile -->\n<!-- SPDX-License-Identifier: AGPL-3.0-only -->\n'
```
2022-06-29 11:42:28 +02:00

26 lines
633 B
Go

// SPDX-FileCopyrightText: 2022 Free Mobile
// SPDX-License-Identifier: AGPL-3.0-only
package daemon
import (
"sync"
)
// lifecycleComponent is the lifecycle part of a component.
type lifecycleComponent struct {
terminateChannel chan struct{}
terminateOnce sync.Once
}
// Terminated will return a channel that will be closed when the daemon
// needs to terminate.
func (c *lifecycleComponent) Terminated() <-chan struct{} {
return c.terminateChannel
}
// Terminate should be called to request termination of a daemon.
func (c *lifecycleComponent) Terminate() {
c.terminateOnce.Do(func() { close(c.terminateChannel) })
}