1
0
mirror of https://git.zx2c4.com/wireguard-go synced 2024-11-15 01:05:15 +01:00
wireguard-go/src/misc.go

35 lines
398 B
Go
Raw Normal View History

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