github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/swarmkit/agent/helpers.go (about) 1 package agent 2 3 import "context" 4 5 // runctx blocks until the function exits, closed is closed, or the context is 6 // cancelled. Call as part of go statement. 7 func runctx(ctx context.Context, closed chan struct{}, errs chan error, fn func(ctx context.Context) error) { 8 select { 9 case errs <- fn(ctx): 10 case <-closed: 11 case <-ctx.Done(): 12 } 13 }