mirror of
https://github.com/xtaci/kcp-go.git
synced 2024-04-21 12:32:15 +00:00
use absolute time
This commit is contained in:
@@ -183,7 +183,7 @@ func newUDPSession(conv uint32, dataShards, parityShards int, l *Listener, conn
|
||||
}
|
||||
|
||||
// start per-session updater
|
||||
SystemTimedSched.Put(sess.update, 0)
|
||||
SystemTimedSched.Put(sess.update, time.Now())
|
||||
|
||||
currestab := atomic.AddUint64(&DefaultSnmp.CurrEstab, 1)
|
||||
maxconn := atomic.LoadUint64(&DefaultSnmp.MaxConn)
|
||||
@@ -593,7 +593,7 @@ func (s *UDPSession) update() {
|
||||
s.uncork()
|
||||
s.mu.Unlock()
|
||||
// self-synchronized timed scheduling
|
||||
SystemTimedSched.Put(s.update, time.Duration(interval)*time.Millisecond)
|
||||
SystemTimedSched.Put(s.update, time.Now().Add(time.Duration(interval)*time.Millisecond))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -125,10 +125,10 @@ func (ts *TimedSched) prepend() {
|
||||
}
|
||||
}
|
||||
|
||||
// Put a function awaiting to be executed
|
||||
func (ts *TimedSched) Put(f func(), duration time.Duration) {
|
||||
// Put a function 'f' awaiting to be executed at 'deadline'
|
||||
func (ts *TimedSched) Put(f func(), deadline time.Time) {
|
||||
ts.prependLock.Lock()
|
||||
ts.prependTasks = append(ts.prependTasks, timedFunc{f, time.Now().Add(duration)})
|
||||
ts.prependTasks = append(ts.prependTasks, timedFunc{f, deadline})
|
||||
ts.prependLock.Unlock()
|
||||
|
||||
select {
|
||||
|
||||
Reference in New Issue
Block a user