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

13
LINES

< > BotCompany Repo | #1017642 // timer_nextFireTime

JavaX fragment (include)

1  
static long timer_nextFireTime(O timer, long now) {
2  
  long best = 0;
3  
  for (O entry : unnull((Collection) getOpt(timer, 'entries))) {
4  
    Long firstTime = cast getOpt(entry, 'firstTime);
5  
    Long period = cast getOpt(entry, 'period);
6  
    if (firstTime != null && period != null)
7  
      if (now >= firstTime) {
8  
        long fireTime = now + period-((now - firstTime) % period);
9  
        if (best == 0 || fireTime < best) best = fireTime;
10  
      }
11  
  }
12  
  ret best;
13  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1017642
Snippet name: timer_nextFireTime
Eternal ID of this version: #1017642/2
Text MD5: 8a7a4735db862a4e9b1a36167dba98ae
Author: stefan
Category: javax / timers
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-31 13:55:02
Source code size: 472 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 322 / 352
Version history: 1 change(s)
Referenced in: [show references]