mirror of https://github.com/nmasse-itix/liche.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
237 B
17 lines
237 B
package main
|
|
|
|
type semaphore struct {
|
|
channel chan bool
|
|
}
|
|
|
|
func newSemaphore(n int) semaphore {
|
|
return semaphore{make(chan bool, n)}
|
|
}
|
|
|
|
func (s semaphore) Request() {
|
|
s.channel <- true
|
|
}
|
|
|
|
func (s semaphore) Release() {
|
|
<-s.channel
|
|
}
|
|
|