| 63 | } |
| 64 | |
| 65 | func (s *bidirectionalStreamStatus) wait(maxWaitForSecondStream time.Duration) error { |
| 66 | <-s.doneChan |
| 67 | |
| 68 | // Only wait for second stream to finish if maxWait is greater than zero |
| 69 | if maxWaitForSecondStream > 0 { |
| 70 | timer := time.NewTimer(maxWaitForSecondStream) |
| 71 | defer timer.Stop() |
| 72 | |
| 73 | select { |
| 74 | case <-timer.C: |
| 75 | return fmt.Errorf("timeout waiting for second stream to finish") |
| 76 | case <-s.doneChan: |
| 77 | return nil |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | return nil |
| 82 | } |
| 83 | func (s *bidirectionalStreamStatus) isAnyDone() bool { |
| 84 | return atomic.LoadUint32(&s.anyDone) > 0 |
| 85 | } |