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

18
LINES

< > BotCompany Repo | #1014921 // serveLongPoll

JavaX fragment (include)

!7

static int serveLongPoll_checkInterval = 100;

// f: func -> O (null or empty string if no result yet)
static O serveLongPoll(long timeout, int interval, O f) {
  long startTime = sysNow();
  while (sysNow() < startTime+timeout) {
    O o = callF(f);
    if (nempty(o)) ret o;
    sleep(serveLongPoll_checkInterval);
  }
  ret "";
}

static O serveLongPoll(long timeout, O f) {
  ret serveLongPoll(timeout, serveLongPoll_checkInterval, f);
}

Author comment

Began life as a copy of #1014866

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: #1014921
Snippet name: serveLongPoll
Eternal ID of this version: #1014921/3
Text MD5: 9a9e15c029e9bb3e0949750f97904f9e
Author: stefan
Category: javax / web / a.i. / android
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-06 14:23:01
Source code size: 462 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 333 / 368
Version history: 2 change(s)
Referenced in: [show references]