depot/go/trains/darwin/util.go

19 lines
225 B
Go
Raw Permalink Normal View History

2021-11-18 22:24:20 +00:00
package darwin
import (
"context"
"time"
)
func Sleep(ctx context.Context, d time.Duration) error {
t := time.NewTicker(d)
defer t.Stop()
select {
case <-t.C:
return nil
case <-ctx.Done():
return ctx.Err()
}
}