MCPcopy
hub / github.com/grpc/grpc-go / waitWhileTrue

Function waitWhileTrue

internal/transport/transport_test.go:2012–2034  ·  view source on GitHub ↗
(t *testing.T, condition func() (bool, error))

Source from the content-addressed store, hash-verified

2010}
2011
2012func waitWhileTrue(t *testing.T, condition func() (bool, error)) {
2013 var (
2014 wait bool
2015 err error
2016 )
2017 timer := time.NewTimer(time.Second * 5)
2018 for {
2019 wait, err = condition()
2020 if wait {
2021 select {
2022 case <-timer.C:
2023 t.Fatal(err)
2024 default:
2025 time.Sleep(50 * time.Millisecond)
2026 continue
2027 }
2028 }
2029 if !timer.Stop() {
2030 <-timer.C
2031 }
2032 break
2033 }
2034}
2035
2036// If any error occurs on a call to Stream.Read, future calls
2037// should continue to return that same error.

Calls 3

StopMethod · 0.95
NewTimerMethod · 0.80
FatalMethod · 0.65

Tested by

no test coverage detected