blob: dd4fa637e14223a6fb63de28e1e9ec22b4e217eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package main
import (
"time"
)
func min(a uint, b uint) uint {
if a > b {
return b
}
return a
}
func sendSignal(c chan struct{}) {
select {
case c <- struct{}{}:
default:
}
}
func stopTimer(timer *time.Timer) {
if !timer.Stop() {
select {
case <-timer.C:
default:
}
}
}
func stoppedTimer() *time.Timer {
timer := time.NewTimer(time.Hour)
stopTimer(timer)
return timer
}
|