// RaceCond runs all functions in parallel and returns the result of the first function that completes with an
// error or with a truthy result.
RaceCond runs all functions in parallel and returns the result of the first function that completes with an
error or with a truthy result.
// RaceCond runs all functions in parallel and returns the result of the first function that completes with an // error or with a truthy result .
func (f *Flow) RaceCond(ctx context.Context, fns ...BoolFunc) (bool, error) {
	if len(fns) == 0 {
		return false, nil
	}
	ctx, cancel := context.WithCancel(ctx)
	defer cancel()
	results := make(chan boolResult)
	f.runAll(len(fns), func(i int) {
		item, err := fns[i](ctx)
		results <- boolResult{item, err}
	}, func() { close(results) })
	var out boolResult
	for res := range results {
		if res.err != nil || res.item {
			cancel()
			out = res
			break
		}
	}
	for range results {
	}
	return out.item, out.err
}
func ( f * Flow ) RaceCond ( ctx context . Context , fns ... BoolFunc ) ( bool , error ) { if len ( fns ) == 0 { return false , nil } ctx , cancel := context . WithCancel ( ctx ) defer cancel ( ) results := make ( chan boolResult ) f . runAll ( len ( fns ) , func ( i int ) { item , err := fns [ i ] ( ctx ) results <- boolResult { item , err } } , func ( ) { close ( results ) } ) var out boolResult for res := range results { if res . err != nil || res . item { cancel ( ) out = res break } } for range results { } return out . item , out . err }
RaceCond runs all functions in parallel and returns the result of the first function that completes with an
error or with a truthy result.
RaceCond runs all functions in parallel and returns the result of the first function that completes with an error or with a truthy result .