From b9f576727fef502fade2370e309d8b238a6a6214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Sun, 22 Dec 2019 13:26:55 +0100 Subject: Add simple scheduler class - no request id or custom time --- .../cloudatlas/agent/timer/TimerScheduler.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/pl/edu/mimuw/cloudatlas/agent/timer/TimerScheduler.java (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/agent/timer/TimerScheduler.java') 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); + } +} -- cgit v1.2.3