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

15
LINES

< > BotCompany Repo | #1027048 // waitUntil - wait for condition, check in regular intervals, poll-wait

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (9964L/55K).

1  
svoid waitUntil(int interval, IF0<Bool> condition) {
2  
  if (condition == null) ret;
3  
  while (!condition.get()) sleep(interval);
4  
}
5  
6  
sbool waitUntil(int interval, double timeout, IF0<Bool> condition) {
7  
  if (condition == null) false;
8  
  long start = sysNow();
9  
  while (sysNow() < start+toMS(timeout))
10  
    if (condition.get())
11  
      true;
12  
    else
13  
      sleep(interval);
14  
  false;
15  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027048
Snippet name: waitUntil - wait for condition, check in regular intervals, poll-wait
Eternal ID of this version: #1027048/5
Text MD5: bb623d1b44ee1d0900c7b9446191568f
Transpilation MD5: 854009b531f6167f4b6943de896f1c57
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-12-11 17:38:24
Source code size: 390 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 299 / 431
Version history: 4 change(s)
Referenced in: [show references]