Browse Source

[flowrate] refactor clock functions (Refs #16)

this commit does not fix the original bug
pull/1842/head
Anton Kaliaev 8 years ago
parent
commit
6b10432463
No known key found for this signature in database GPG Key ID: 7B6881D965918214
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      flowrate/util.go

+ 3
- 3
flowrate/util.go View File

@ -15,16 +15,16 @@ const clockRate = 20 * time.Millisecond
// czero is the process start time rounded down to the nearest clockRate
// increment.
var czero = time.Duration(time.Now().UnixNano()) / clockRate * clockRate
var czero = time.Now().Round(clockRate)
// clock returns a low resolution timestamp relative to the process start time.
func clock() time.Duration {
return time.Duration(time.Now().UnixNano())/clockRate*clockRate - czero
return time.Now().Round(clockRate).Sub(czero)
}
// clockToTime converts a clock() timestamp to an absolute time.Time value.
func clockToTime(c time.Duration) time.Time {
return time.Unix(0, int64(czero+c))
return czero.Add(c)
}
// clockRound returns d rounded to the nearest clockRate increment.


Loading…
Cancel
Save