m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/pl/edu/mimuw/cloudatlas
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/pl/edu/mimuw/cloudatlas')
-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);
+ }
+}