util.go 440 B

12345678910111213141516171819202122232425262728
  1. package yamux
  2. // asyncSendErr is used to try an async send of an error
  3. func asyncSendErr(ch chan error, err error) {
  4. if ch == nil {
  5. return
  6. }
  7. select {
  8. case ch <- err:
  9. default:
  10. }
  11. }
  12. // asyncNotify is used to signal a waiting goroutine
  13. func asyncNotify(ch chan struct{}) {
  14. select {
  15. case ch <- struct{}{}:
  16. default:
  17. }
  18. }
  19. // min computes the minimum of two values
  20. func min(a, b uint32) uint32 {
  21. if a < b {
  22. return a
  23. }
  24. return b
  25. }