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

24
LINES

< > BotCompany Repo | #1006311 - smartTimerTask - create TimerTask with automatic fix for hibernation problem & automatic cancellation on program clean-up

JavaX fragment (include)

// r may return false to cancel timer
static TimerTask smartTimerTask(O r, java.util.Timer timer, long delay) {
  ret SmartTimerTask(r, timer, delay, _threadInfo());
}

srecord noeq SmartTimerTask(O r, java.util.Timer timer, long delay, O threadInfo) extends TimerTask {
  long lastRun;
  
  public void run() {
    if (!licensed())
      timer.cancel();
    else {
      _threadInheritInfo(threadInfo);
      temp tempActivity(r);
      lastRun = fixTimestamp(lastRun);
      long now = now();
      if (now >= lastRun + delay*0.9) {
        lastRun = now;
        if (eq(false, pcallF(r)))
          timer.cancel();
      }
    }
  }
}

Author comment

Began life as a copy of #1004684

download  show line numbers  debug dex   

Travelled to 11 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, sawdedvomwva, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1006311
Snippet name: smartTimerTask - create TimerTask with automatic fix for hibernation problem & automatic cancellation on program clean-up
Eternal ID of this version: #1006311/10
Text MD5: 2b83f745aab8832d15e5dcb5e1972889
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-26 13:35:15
Source code size: 660 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 324 / 360
Version history: 9 change(s)
Referenced in: [show references]