Files
zrepl_patched/util/semaphore.go
T
2018-02-27 00:20:32 +01:00

18 lines
229 B
Go

package util
type Semaphore struct {
c chan struct{}
}
func NewSemaphore(cap int) Semaphore {
return Semaphore{make(chan struct{}, cap)}
}
func (s Semaphore) Down() {
s.c <- struct{}{}
}
func (s Semaphore) Up() {
<-s.c
}