1package yamux
2
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
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}
44