forked from quic-go/quic-go
add rtt stats
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"crypto/rand"
|
||||
"io"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ReadStream is the read part of a QUIC stream
|
||||
@@ -172,6 +173,22 @@ func MaxInt64(a, b int64) int64 {
|
||||
return b
|
||||
}
|
||||
|
||||
// MaxDuration returns the max duration
|
||||
func MaxDuration(a, b time.Duration) time.Duration {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// AbsDuration returns the absolute value of a time duration
|
||||
func AbsDuration(d time.Duration) time.Duration {
|
||||
if d >= 0 {
|
||||
return d
|
||||
}
|
||||
return -d
|
||||
}
|
||||
|
||||
// RandomBit returns a cryptographically secure random bit (encoded as true / false)
|
||||
func RandomBit() (bool, error) {
|
||||
// ToDo: it's probably more efficient to read a bigger slice of random numbers at once and to cache them somewhere
|
||||
|
||||
Reference in New Issue
Block a user