+ * While it is perfectly fine for clients to call the DSF executor with
+ * an object only implementing the Runnable/Callable interface, the DsfExecutable
+ * contains fields and methods that used for debugging and tracing when
+ * tracing is enabled.
+ */
+public class DsfExecutable {
+ final StackTraceElement[] fCreatedAt;
+ final DefaultDsfExecutor.TracingWrapper fCreatedBy;
+
+ @SuppressWarnings("unchecked")
+ public DsfExecutable() {
+ // Use assertion flag (-ea) to jre to avoid affecting performance when not debugging.
+ boolean assertsEnabled = false;
+ assert assertsEnabled = true;
+ if (assertsEnabled || DefaultDsfExecutor.DEBUG_EXECUTOR) {
+ // Find the runnable/callable that is currently running.
+ DefaultDsfExecutor executor = DefaultDsfExecutor.fThreadToExecutorMap.get(Thread.currentThread());
+ if (executor != null) {
+ fCreatedBy = executor.fCurrentlyExecuting;
+ } else {
+ fCreatedBy = null;
+ }
+
+ // Get the stack trace and find the first method that is not a
+ // constructor of this object.
+ StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
+ Class thisClass = getClass();
+ Set
@@ -18,45 +19,5 @@ package org.eclipse.dd.dsf.concurrent;
* contains fields and methods that used for debugging and tracing when
* tracing is enabled.
*/
-abstract public class DsfRunnable implements Runnable {
- private StackTraceElement [] fStackTrace = null;
- private Runnable fSubmittedBy = null;
-
- public DsfRunnable() {
- // Use assertion flag (-ea) to jre to avoid affecting performance when not debugging.
- boolean assertsEnabled = false;
- assert assertsEnabled = true;
- if (assertsEnabled || DefaultDsfExecutor.DEBUG_EXECUTOR) {
- fStackTrace = Thread.currentThread().getStackTrace();
- }
- }
-
- public String toString () {
- StringBuilder builder = new StringBuilder() ;
- // If assertions are not turned on.
- builder.append(super.toString());
- if (fStackTrace != null) {
- builder.append ( "\n\tCreated at" ) ;
-
- // ommit the first elements in the stack trace
- for (int i = 3; i < fStackTrace.length && i < 13; i++) {
- if (i > 3) builder.append ( "\tat " ) ;
- builder.append( fStackTrace [ i ] .toString ()) ;
- builder.append( "\n" ) ;
- }
- if (fStackTrace.length > 13) {
- builder.append("\t at ...");
- }
- }
- if (fSubmittedBy != null) {
- builder.append("Submitted by \n");
- builder.append(fSubmittedBy.toString());
- }
-
- return builder.toString();
- }
-
- void setSubmittedBy(Runnable runnable) {
- fSubmittedBy = runnable;
- }
+abstract public class DsfRunnable extends DsfExecutable implements Runnable {
}
diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/GetDataDone.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/GetDataDone.java
index 3a8784d10ee..c1e9af9ce8a 100644
--- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/GetDataDone.java
+++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/GetDataDone.java
@@ -30,4 +30,12 @@ public abstract class GetDataDone