Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

13
LINES

< > BotCompany Repo | #1015617 // expectTimeJump (because of wake-up from suspend mode)

JavaX fragment (include)

1  
static bool expectTimeJump(double secondsToWait, O onMessage) {
2  
  long diff = now()-sysNow();
3  
  long start = sysNow();
4  
  while (elapsedSeconds(start) < secondsToWait) {
5  
    sleep(500);
6  
    long diff2 = now()-sysNow()-diff;
7  
    if (abs(diff2) > 100) {
8  
      logQuotedWithDate(timeJumpLog(), diff2 + " ms");
9  
      ret true with callF(onMessage, "Slept " + formatDouble(toSeconds(diff2), 1) + " seconds!");
10  
    }
11  
  }
12  
  ret false with callF(onMessage, "No time jump occurred in " + secondsToWait + " seconds");
13  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1015617
Snippet name: expectTimeJump (because of wake-up from suspend mode)
Eternal ID of this version: #1015617/7
Text MD5: 90d81c9ac35eda566f230183d5bea772
Author: stefan
Category: javax / os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-23 13:13:50
Source code size: 520 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 349 / 406
Version history: 6 change(s)
Referenced in: [show references]