2018-07-04 10:51:47 +00:00
|
|
|
package yamux
|
|
|
|
|
|
|
|
// asyncSendErr is used to try an async send of an error
|
|
|
|
func asyncSendErr(ch chan error, err error) {
|
|
|
|
if ch == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
select {
|
|
|
|
case ch <- err:
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// asyncNotify is used to signal a waiting goroutine
|
|
|
|
func asyncNotify(ch chan struct{}) {
|
|
|
|
select {
|
|
|
|
case ch <- struct{}{}:
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-09 07:24:20 +00:00
|
|
|
// min computes the minimum of a set of values
|
|
|
|
func min(values ...uint32) uint32 {
|
|
|
|
m := values[0]
|
|
|
|
for _, v := range values[1:] {
|
|
|
|
if v < m {
|
|
|
|
m = v
|
|
|
|
}
|
2018-07-04 10:51:47 +00:00
|
|
|
}
|
2019-06-09 07:24:20 +00:00
|
|
|
return m
|
2018-07-04 10:51:47 +00:00
|
|
|
}
|