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

41
LINES

< > BotCompany Repo | #1022136 // JavaX Cron CRUD

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (14368L/80K).

!7

concept CronJob {
  bool enabled = true;
  long lastStart, lastEnd, nextStart;
  S name;
  S code;
  S lastError;
  bool realEval;
}

set flag DynModule.

cmodule CronCRUD > DynCRUD<CronJob> {
  start {
    doEvery(10.0, rEnter bingo);
  }
  
  void bingo {
    for (final CronJob job : list()) pcall {
      if (job.enabled && job.nextStart > 0 && job.nextStart <= now()) {
        cset(job, lastStart := now(), nextStart := 0);
        programLog(print("STARTING JOB: " + job);
        startThread(job.name, r {
          try {
            if (job.realEval)
              dm_javaEval(job.code);
            else
              dm_javaEvalOrInterpret(job.code);
            cset(job, lastError := null);
            programLog(print("JOB COMPLETE: " + job);
          } catch e {
            cset(job, lastError := getStackTrace(e));
          } finally {
            cset(job, lastEnd := now());
          }
        });
      }
    }
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1022136
Snippet name: JavaX Cron CRUD
Eternal ID of this version: #1022136/5
Text MD5: 33a56c8be3cf7d3b5ed4541a8467839f
Transpilation MD5: 81a1538da197ec0a68578a880bc68acc
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-08 17:48:33
Source code size: 984 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 278 / 394
Version history: 4 change(s)
Referenced in: [show references]