mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
提交origin2.0版本
This commit is contained in:
15
util/semaphore/semaphore.go
Normal file
15
util/semaphore/semaphore.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package semaphore
|
||||
|
||||
type Semaphore chan struct{}
|
||||
|
||||
func MakeSemaphore(n int) Semaphore {
|
||||
return make(Semaphore, n)
|
||||
}
|
||||
|
||||
func (s Semaphore) Acquire() {
|
||||
s <- struct{}{}
|
||||
}
|
||||
|
||||
func (s Semaphore) Release() {
|
||||
<-s
|
||||
}
|
||||
Reference in New Issue
Block a user