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

18
LINES

< > BotCompany Repo | #1014921 // serveLongPoll

JavaX fragment (include)

1  
!7
2  
3  
static int serveLongPoll_checkInterval = 100;
4  
5  
// f: func -> O (null or empty string if no result yet)
6  
static O serveLongPoll(long timeout, int interval, O f) {
7  
  long startTime = sysNow();
8  
  while (sysNow() < startTime+timeout) {
9  
    O o = callF(f);
10  
    if (nempty(o)) ret o;
11  
    sleep(serveLongPoll_checkInterval);
12  
  }
13  
  ret "";
14  
}
15  
16  
static O serveLongPoll(long timeout, O f) {
17  
  ret serveLongPoll(timeout, serveLongPoll_checkInterval, f);
18  
}

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: 404 / 442
Version history: 2 change(s)
Referenced in: [show references]