mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-03-02 05:57:09 -05:00
Bumps [github.com/open-policy-agent/opa](https://github.com/open-policy-agent/opa) from 1.4.2 to 1.5.0. - [Release notes](https://github.com/open-policy-agent/opa/releases) - [Changelog](https://github.com/open-policy-agent/opa/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-policy-agent/opa/compare/v1.4.2...v1.5.0) --- updated-dependencies: - dependency-name: github.com/open-policy-agent/opa dependency-version: 1.5.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
65 lines
1.0 KiB
Go
65 lines
1.0 KiB
Go
package fsnotify
|
|
|
|
import "sync"
|
|
|
|
type shared struct {
|
|
Events chan Event
|
|
Errors chan error
|
|
done chan struct{}
|
|
mu sync.Mutex
|
|
}
|
|
|
|
func newShared(ev chan Event, errs chan error) *shared {
|
|
return &shared{
|
|
Events: ev,
|
|
Errors: errs,
|
|
done: make(chan struct{}),
|
|
}
|
|
}
|
|
|
|
// Returns true if the event was sent, or false if watcher is closed.
|
|
func (w *shared) sendEvent(e Event) bool {
|
|
if e.Op == 0 {
|
|
return true
|
|
}
|
|
select {
|
|
case <-w.done:
|
|
return false
|
|
case w.Events <- e:
|
|
return true
|
|
}
|
|
}
|
|
|
|
// Returns true if the error was sent, or false if watcher is closed.
|
|
func (w *shared) sendError(err error) bool {
|
|
if err == nil {
|
|
return true
|
|
}
|
|
select {
|
|
case <-w.done:
|
|
return false
|
|
case w.Errors <- err:
|
|
return true
|
|
}
|
|
}
|
|
|
|
func (w *shared) isClosed() bool {
|
|
select {
|
|
case <-w.done:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
// Mark as closed; returns true if it was already closed.
|
|
func (w *shared) close() bool {
|
|
w.mu.Lock()
|
|
defer w.mu.Unlock()
|
|
if w.isClosed() {
|
|
return true
|
|
}
|
|
close(w.done)
|
|
return false
|
|
}
|