status-go/vendor/github.com/libp2p/go-yamux/util.go

32 lines
501 B
Go
Raw Normal View History

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
}
}
2019-06-09 07:24:20 +00:00
return m
}