From 8e8a49a7477042d5424ecf8ddc432d9297f3e005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Wed, 25 Dec 2019 12:54:37 +0100 Subject: Add messaging capability to tasks --- .../mimuw/cloudatlas/agent/modules/TimerScheduledTask.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/TimerScheduledTask.java') diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/TimerScheduledTask.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/TimerScheduledTask.java index 4b933b5..7a0da70 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/TimerScheduledTask.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/TimerScheduledTask.java @@ -1,7 +1,19 @@ package pl.edu.mimuw.cloudatlas.agent.modules; +import pl.edu.mimuw.cloudatlas.agent.messages.AgentMessage; + import java.util.TimerTask; public abstract class TimerScheduledTask extends TimerTask { + private TimerScheduler scheduler; + public abstract void run(); + + public void setScheduler(TimerScheduler scheduler) { + this.scheduler = scheduler; + } + + protected void sendMessage(AgentMessage msg) throws InterruptedException { + this.scheduler.passMessageFromTask(msg); + } } -- cgit v1.2.3