static long timeJumpDetector_lastTimeJump; // in sys time static long timeJumpDetector_lastTimeJumpLength; sbool timeJumpDetector_verbose; static L timeJumpDetector_onTimeJump = synchroList(); static int timeJumpDetector_minJump = 5000; static void timeJumpDetector() { doEvery(1000, new Runnable { long diff = now()-sysNow(); long lastSysNow = sysNow(); public void run() { long sysNow = sysNow(); long newDiff = now()-sysNow; long d = newDiff-diff; if (timeJumpDetector_verbose) print("timeJumpDetector: sysNow=" + sysNow + ", diff=" + newDiff); if (abs(d) <= timeJumpDetector_minJump && /*isWindows() &&*/ sysNow-lastSysNow >= 10000) d = sysNow-lastSysNow-10000; if (abs(d) > timeJumpDetector_minJump) { diff = now()-sysNow(); timeJumpDetector_lastTimeJump = sysNow(); timeJumpDetector_lastTimeJumpLength = d; printAndProgramLog(ymd_hms() + ": Time jump occurred! (" + formatDouble(toSeconds(d), 1) + " seconds)"); if (nempty(timeJumpDetector_onTimeJump)) thread { pcallFAll(concurrentlyIterateList(timeJumpDetector_onTimeJump)); } } diff = newDiff; lastSysNow = sysNow; } }); }
Began life as a copy of #1015617
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1015620 |
Snippet name: | timeJumpDetector (notices wake-up from suspend/hibernate mode) |
Eternal ID of this version: | #1015620/20 |
Text MD5: | 16d4cdfc3f6537e917feb56c7289ef80 |
Author: | stefan |
Category: | javax / os |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-11-12 16:29:35 |
Source code size: | 1267 bytes / 33 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 465 / 553 |
Version history: | 19 change(s) |
Referenced in: | [show references] |