mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 10:55:42 +03:00
The PR we needed https://github.com/shirou/gopsutil/pull/889 has been merged upstream, which means we can use upstream rather than our fork of psutil.
19 lines
317 B
Go
19 lines
317 B
Go
package common
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
// Sleep awaits for provided interval.
|
|
// Can be interrupted by context cancelation.
|
|
func Sleep(ctx context.Context, interval time.Duration) error {
|
|
var timer = time.NewTimer(interval)
|
|
select {
|
|
case <-ctx.Done():
|
|
return ctx.Err()
|
|
case <-timer.C:
|
|
return nil
|
|
}
|
|
}
|