From ecb4673c21281143b394080b7c7ac42ccccd8fc4 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Mon, 27 Sep 2010 03:11:41 +0200
Subject: RunnableTask: Add attachment

---
 src/java/com/jogamp/common/util/RunnableTask.java | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

(limited to 'src/java/com')

diff --git a/src/java/com/jogamp/common/util/RunnableTask.java b/src/java/com/jogamp/common/util/RunnableTask.java
index f885f46..eac6255 100644
--- a/src/java/com/jogamp/common/util/RunnableTask.java
+++ b/src/java/com/jogamp/common/util/RunnableTask.java
@@ -36,6 +36,7 @@ public class RunnableTask implements Runnable {
     Runnable runnable;
     Object notifyObject;
     boolean catchExceptions;
+    Object attachment;
 
     Throwable runnableException;
     long ts0, ts1, ts2;
@@ -57,6 +58,22 @@ public class RunnableTask implements Runnable {
         ts2 = 0;
     }
 
+    public Runnable getRunnable() {
+        return runnable;
+    }
+
+    /** 
+     * Attach a custom object to this task. 
+     * Useful to piggybag further information, ie tag a task final. 
+     */
+    public void setAttachment(Object o) {
+        attachment = o;
+    }
+
+    public Object getAttachment() {
+        return attachment;
+    }
+
     public void run() {
         ts1 = System.currentTimeMillis();
         if(null == notifyObject) {
@@ -109,7 +126,7 @@ public class RunnableTask implements Runnable {
     public long getDurationTotal() { return ts2 - ts0; }
 
     public String toString() {
-        return "RunnableTask[executed "+isExecuted()+", t2-t0 "+getDurationTotal()+", t2-t1 "+getDurationInExec()+", t1-t0 "+getDurationInQueue()+", throwable "+getThrowable()+", Runnable "+runnable+"]";
+        return "RunnableTask[executed "+isExecuted()+", t2-t0 "+getDurationTotal()+", t2-t1 "+getDurationInExec()+", t1-t0 "+getDurationInQueue()+", throwable "+getThrowable()+", Runnable "+runnable+", Attachment "+attachment+"]";
     }
 }
 
-- 
cgit v1.2.3