wireguard-go/src/misc.go
2017-07-01 23:29:22 +02:00

35 lines
398 B
Go

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
}