mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-22 11:59:40 +01:00
simplify semaphore release code
This commit is contained in:
parent
2e9a0d4b2d
commit
549d06bc98
@ -5,8 +5,6 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"log"
|
|
||||||
"runtime/debug"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -67,15 +65,7 @@ func (semaphore *Semaphore) AcquireWithContext(ctx context.Context) (acquired bo
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release releases a semaphore. It never blocks. (This is not a license
|
// Release releases a semaphore.
|
||||||
// to program spurious releases.)
|
|
||||||
func (semaphore *Semaphore) Release() {
|
func (semaphore *Semaphore) Release() {
|
||||||
select {
|
<-(*semaphore)
|
||||||
case <-(*semaphore):
|
|
||||||
// good
|
|
||||||
default:
|
|
||||||
// spurious release
|
|
||||||
log.Printf("spurious semaphore release (full to capacity %d)", cap(*semaphore))
|
|
||||||
debug.PrintStack()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user