mirror of
https://github.com/mayflower/docker-ls.git
synced 2025-11-28 00:01:09 +03:00
20 lines
243 B
Go
20 lines
243 B
Go
package connector
|
|
|
|
type semaphore chan int
|
|
|
|
func (s semaphore) Lock() {
|
|
s <- 1
|
|
}
|
|
|
|
func (s semaphore) Unlock() {
|
|
_ = <-s
|
|
}
|
|
|
|
func newSemaphore(limit uint) semaphore {
|
|
if limit == 0 {
|
|
limit = 1
|
|
}
|
|
|
|
return semaphore(make(chan int, limit))
|
|
}
|