erigon-pulse/cmd/observer/utils/sleep.go

16 lines
236 B
Go
Raw Normal View History

package utils
import (
"context"
"time"
)
func Sleep(parentContext context.Context, timeout time.Duration) {
if timeout <= 0 {
return
}
ctx, cancel := context.WithTimeout(parentContext, timeout)
defer cancel()
<-ctx.Done()
}