From cf683954a224e89978766317e912025789da21aa Mon Sep 17 00:00:00 2001 From: xtaci Date: Sat, 1 Jun 2019 18:23:55 +0800 Subject: [PATCH] move currentMs() to kcp.go --- kcp.go | 7 +++++++ sess.go | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/kcp.go b/kcp.go index fb5758e..c0aa9ec 100644 --- a/kcp.go +++ b/kcp.go @@ -3,6 +3,7 @@ package kcp import ( "encoding/binary" "sync/atomic" + "time" ) const ( @@ -29,6 +30,12 @@ const ( IKCP_PROBE_LIMIT = 120000 // up to 120 secs to probe window ) +// monotonic reference time point +var refTime time.Time = time.Now() + +// currentMs returns current elasped monotonic milliseconds since program startup +func currentMs() uint32 { return uint32(time.Now().Sub(refTime) / time.Millisecond) } + // output_callback is a prototype which ought capture conn and call conn.Write type output_callback func(buf []byte, size int) diff --git a/sess.go b/sess.go index 48217ae..589d5cd 100644 --- a/sess.go +++ b/sess.go @@ -984,9 +984,3 @@ func NewConn(raddr string, block BlockCrypt, dataShards, parityShards int, conn } return NewConn2(udpaddr, block, dataShards, parityShards, conn) } - -// monotonic reference time point -var refTime time.Time = time.Now() - -// currentMs returns current elasped monotonic milliseconds since program startup -func currentMs() uint32 { return uint32(time.Now().Sub(refTime) / time.Millisecond) }