We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 383548f commit e28926cCopy full SHA for e28926c
control/semaphore.go
@@ -0,0 +1,25 @@
1
+package control
2
+
3
+type (
4
+ Semaphore interface {
5
+ Acquire()
6
+ Release()
7
+ }
8
+ _semaphore struct {
9
+ c chan struct{}
10
11
+)
12
13
+func NewSemaphore(count uint64) Semaphore {
14
+ return &_semaphore{
15
+ c: make(chan struct{}, count),
16
17
+}
18
19
+func (s *_semaphore) Acquire() {
20
+ s.c <- struct{}{}
21
22
23
+func (s *_semaphore) Release() {
24
+ <-s.c
25
0 commit comments