Added option to wait for signal indefinitely

gql_cataclysm
noah metz 2023-07-30 13:19:51 -06:00
parent 4e31a6763d
commit 1af94520a8
1 changed files with 4 additions and 1 deletions

@ -57,7 +57,10 @@ func WaitForReadResult(listener chan *ReadResultSignal, timeout time.Duration, i
func WaitForSignal[S Signal](ctx * Context, listener *ListenerExt, timeout time.Duration, signal_type SignalType, check func(S)bool) (S, error) { func WaitForSignal[S Signal](ctx * Context, listener *ListenerExt, timeout time.Duration, signal_type SignalType, check func(S)bool) (S, error) {
var zero S var zero S
timeout_channel := time.After(timeout) var timeout_channel <- chan time.Time
if timeout > 0 {
timeout_channel = time.After(timeout)
}
for true { for true {
select { select {
case signal := <- listener.Chan: case signal := <- listener.Chan: