You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Go's timers appear to use nanotime(). nanotime() at the moment uses CLOCK_MONOTONIC. This is all good and well, until you're trying to do networking on a mobile device. Imagine a protocol that is supposed to do something upon the expiration of a timer with a certain bit of wiggle room. If it doesn't after the wiggle room, availability is affected. If a smartphone goes to sleep, when it wakes back up, if it leaves off counting where it left off, the timer's expiration will happen way too late. Instead, when it wakes back up, if the timer has already expired, it should be immediately expired.
Fortunately, Linux offers CLOCK_BOOTTIME, which according to the man page is identical to CLOCK_MONOTONIC, except it takes into account suspend. (It isn't susceptible to the administrator fiddling the clock like CLOCK_REALTIME is, which obviously would not be what we want.) Check out the clock_gettime man page for descriptions.
The patch for this is straightforward, but I figure I should post about it here first to see if you've already thought about this.
The text was updated successfully, but these errors were encountered:
Go's timers appear to use nanotime(). nanotime() at the moment uses CLOCK_MONOTONIC. This is all good and well, until you're trying to do networking on a mobile device. Imagine a protocol that is supposed to do something upon the expiration of a timer with a certain bit of wiggle room. If it doesn't after the wiggle room, availability is affected. If a smartphone goes to sleep, when it wakes back up, if it leaves off counting where it left off, the timer's expiration will happen way too late. Instead, when it wakes back up, if the timer has already expired, it should be immediately expired.
Fortunately, Linux offers CLOCK_BOOTTIME, which according to the man page is identical to CLOCK_MONOTONIC, except it takes into account suspend. (It isn't susceptible to the administrator fiddling the clock like CLOCK_REALTIME is, which obviously would not be what we want.) Check out the clock_gettime man page for descriptions.
The patch for this is straightforward, but I figure I should post about it here first to see if you've already thought about this.
The text was updated successfully, but these errors were encountered: