]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blame - vendor/github.com/hashicorp/yamux/util.go
Merge pull request #32 from ndench/0.12-compatibility
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / hashicorp / yamux / util.go
CommitLineData
bae9f6d2
JC
1package yamux
2
107c1cdb
ND
3import (
4 "sync"
5 "time"
6)
7
8var (
9 timerPool = &sync.Pool{
10 New: func() interface{} {
11 timer := time.NewTimer(time.Hour * 1e6)
12 timer.Stop()
13 return timer
14 },
15 }
16)
17
bae9f6d2
JC
18// asyncSendErr is used to try an async send of an error
19func asyncSendErr(ch chan error, err error) {
20 if ch == nil {
21 return
22 }
23 select {
24 case ch <- err:
25 default:
26 }
27}
28
29// asyncNotify is used to signal a waiting goroutine
30func asyncNotify(ch chan struct{}) {
31 select {
32 case ch <- struct{}{}:
33 default:
34 }
35}
36
37// min computes the minimum of two values
38func min(a, b uint32) uint32 {
39 if a < b {
40 return a
41 }
42 return b
43}