m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagdalena Grodzińska <mag.grodzinska@gmail.com>2019-12-22 13:26:55 +0100
committerMagdalena Grodzińska <mag.grodzinska@gmail.com>2019-12-23 19:33:04 +0100
commitb9f576727fef502fade2370e309d8b238a6a6214 (patch)
treee02550c0dbad2354fb54f1cef377b6a5c9e306af
parent0949c9d56c595c0e253e6a35604fb2b9af46f82a (diff)
Add simple scheduler class - no request id or custom time
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/timer/TimerScheduler.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/timer/TimerScheduler.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/timer/TimerScheduler.java
new file mode 100644
index 0000000..8eddb21
--- /dev/null
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/timer/TimerScheduler.java
@@ -0,0 +1,27 @@
+package pl.edu.mimuw.cloudatlas.agent.timer;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+/**
+ * Initializes a timer within a constructor during its attachment to the executor
+ * Runs in a thread separate from executor - maybe refactor so that it's attached to executor's thread
+ *
+ * Handle used to attach tasks to schedule
+ * Tasks declared as inherited from TimerTask
+ */
+public class TimerScheduler {
+ private Timer timer;
+
+ TimerScheduler() {
+ this.timer = new Timer();
+ }
+
+ public void handle(TimerTask task, long delay, long period) {
+ this.timer.scheduleAtFixedRate(task, delay, period);
+ }
+
+ public void handle(TimerTask task, long delay) {
+ this.timer.schedule(task, delay);
+ }
+}