Files
releases/v1/debug/latch.go
Anders Eknert bd5ceb5142 Enable unused-receiver linter (revive) (#7448)
Signed-off-by: Anders Eknert <anders@styra.com>
2025-03-14 11:41:25 +01:00

39 lines
604 B
Go

// Copyright 2024 The OPA Authors. All rights reserved.
// Use of this source code is governed by an Apache2
// license that can be found in the LICENSE file.
package debug
import "sync"
type latch struct {
paused bool
waitGroup sync.WaitGroup
lock sync.Mutex
}
func (l *latch) block() {
l.lock.Lock()
defer l.lock.Unlock()
if !l.paused {
l.waitGroup.Add(1)
l.paused = true
}
}
func (l *latch) unblock() {
l.lock.Lock()
defer l.lock.Unlock()
if l.paused {
l.waitGroup.Done()
l.paused = false
}
}
func (l *latch) wait() {
l.waitGroup.Wait()
}
func (*latch) Close() {
}