(ctx context.Context, d time.Duration)
| 1079 | } |
| 1080 | |
| 1081 | func sleepWithContext(ctx context.Context, d time.Duration) { |
| 1082 | if d <= 0 { |
| 1083 | return |
| 1084 | } |
| 1085 | timer := time.NewTimer(d) |
| 1086 | defer timer.Stop() |
| 1087 | if ctx == nil { |
| 1088 | <-timer.C |
| 1089 | return |
| 1090 | } |
| 1091 | select { |
| 1092 | case <-ctx.Done(): |
| 1093 | return |
| 1094 | case <-timer.C: |
| 1095 | return |
| 1096 | } |
| 1097 | } |
no test coverage detected