mirror of
https://github.com/containers/podman.git
synced 2025-12-04 20:28:40 +08:00
Update module github.com/shirou/gopsutil to v4
Signed-off-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
This commit is contained in:
22
vendor/github.com/shirou/gopsutil/v4/internal/common/sleep.go
generated
vendored
Normal file
22
vendor/github.com/shirou/gopsutil/v4/internal/common/sleep.go
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Sleep awaits for provided interval.
|
||||
// Can be interrupted by context cancellation.
|
||||
func Sleep(ctx context.Context, interval time.Duration) error {
|
||||
timer := time.NewTimer(interval)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
if !timer.Stop() {
|
||||
<-timer.C
|
||||
}
|
||||
return ctx.Err()
|
||||
case <-timer.C:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user