Files
origin/util/semaphore/semaphore.go
2020-03-28 09:57:16 +08:00

16 lines
206 B
Go

package semaphore
type Semaphore chan struct{}
func MakeSemaphore(n int) Semaphore {
return make(Semaphore, n)
}
func (s Semaphore) Acquire() {
s <- struct{}{}
}
func (s Semaphore) Release() {
<-s
}