|
@@ -5,8 +5,6 @@ package utils
|
5
|
5
|
|
6
|
6
|
import (
|
7
|
7
|
"context"
|
8
|
|
- "log"
|
9
|
|
- "runtime/debug"
|
10
|
8
|
"time"
|
11
|
9
|
)
|
12
|
10
|
|
|
@@ -67,15 +65,7 @@ func (semaphore *Semaphore) AcquireWithContext(ctx context.Context) (acquired bo
|
67
|
65
|
return
|
68
|
66
|
}
|
69
|
67
|
|
70
|
|
-// Release releases a semaphore. It never blocks. (This is not a license
|
71
|
|
-// to program spurious releases.)
|
|
68
|
+// Release releases a semaphore.
|
72
|
69
|
func (semaphore *Semaphore) Release() {
|
73
|
|
- select {
|
74
|
|
- case <-(*semaphore):
|
75
|
|
- // good
|
76
|
|
- default:
|
77
|
|
- // spurious release
|
78
|
|
- log.Printf("spurious semaphore release (full to capacity %d)", cap(*semaphore))
|
79
|
|
- debug.PrintStack()
|
80
|
|
- }
|
|
70
|
+ <-(*semaphore)
|
81
|
71
|
}
|