mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-05 10:32:19 +00:00
16 lines
236 B
Go
16 lines
236 B
Go
|
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()
|
||
|
}
|