wireguard-go/src/misc.go

35 lines
398 B
Go
Raw Normal View History

package main
2017-07-01 21:29:22 +00:00
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:
}
}
2017-07-01 21:29:22 +00:00
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
}