1
0
mirror of https://github.com/eventials/goevents.git synced 2025-04-24 13:48:53 +08:00
eventials.goevents/amqp/semaphore.go
Alexandre Vicenzi 5df455293c Max workers.
2017-06-15 14:08:01 -03:00

20 lines
236 B
Go

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
}