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

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

Libraryless. Click here for Pure Java version (2544L/16K).

svoid waitUntil(int interval, IF0<Bool> condition) {
  if (condition == null) ret;
  while (!condition.get()) sleep(interval);
}

sbool waitUntil(int interval, double timeout, IF0<Bool> condition) {
  if (condition == null) false;
  long start = sysNow();
  while (sysNow() < start+toMS(timeout))
    if (condition.get())
      true;
    else
      sleep(interval);
  false;
}

download  show line numbers  debug dex   

Travelled to 5 computer(s): bhatertpkbcr, mqqgnosmbjvj, pzhvpgtvlbxg, tvejysmllsmz, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027048
Snippet name: waitUntil - wait for condition, check in regular intervals
Eternal ID of this version: #1027048/4
Text MD5: bb623d1b44ee1d0900c7b9446191568f
Transpilation MD5: 3302b88084fe78cc4884de9cdba6ab0d
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-01 17:05:05
Source code size: 390 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 29 / 69
Version history: 3 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1027048 & http://1027048.tinybrain.de