1
0
mirror of https://github.com/eventials/goevents.git synced 2025-04-28 13:48:49 +08:00
eventials.goevents/amqp/semaphore.go

20 lines
236 B
Go
Raw Normal View History

2017-06-15 12:07:50 -03:00
package amqp
type Semaphore struct {
c chan bool
}
func NewSemaphore(size int) Semaphore {
return Semaphore{
c: make(chan bool, size),
}
}
func (s *Semaphore) Acquire() {
s.c <- true
}
func (s *Semaphore) Release() {
<-s.c
}