mirror of
https://github.com/eventials/goevents.git
synced 2025-04-24 13:48:53 +08:00
20 lines
236 B
Go
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
|
|
}
|