diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/ImmediateExecutor.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/ImmediateExecutor.java new file mode 100644 index 00000000000..4e955b70867 --- /dev/null +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/ImmediateExecutor.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2007 Wind River Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.dd.dsf.concurrent; + +import java.util.concurrent.Executor; + +/** + * Executor that executes a runnable immediately as it is submitted. This + * executor is useful for clients that need to create RequestMonitor + * objects, but which do not have their own executor. + * @see RequestMonitor + */ +public class ImmediateExecutor implements Executor { + private static ImmediateExecutor fInstance = new ImmediateExecutor(); + + public static Executor getInstance() { + return fInstance; + } + + public void execute(Runnable command) { + command.run(); + } +} diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Query.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Query.java index ee1bec45ded..a490ab2df4f 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Query.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Query.java @@ -12,7 +12,6 @@ package org.eclipse.dd.dsf.concurrent; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executor; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -112,13 +111,7 @@ abstract public class Query extends DsfRunnable * shut down. In that case, the DSF executor may throw a * RejectedExecutionException which would have to be handled by the query. */ - Executor rmExecutor = new Executor() { - public void execute(Runnable command) { - command.run(); - } - }; - - execute(new DataRequestMonitor(rmExecutor, null) { + execute(new DataRequestMonitor(ImmediateExecutor.getInstance(), null) { @Override public void handleCompleted() { if (getStatus().isOK()) fSync.doSet(getData()); diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/RequestMonitor.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/RequestMonitor.java index 9a7c0343fbf..4a6aa955515 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/RequestMonitor.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/RequestMonitor.java @@ -159,7 +159,7 @@ public class RequestMonitor { @Override public String toString() { - return "RequestMonitor: " + getStatus().toString(); //$NON-NLS-1$ + return "RequestMonitor (" + super.toString() + "): " + getStatus().toString(); //$NON-NLS-1$ //$NON-NLS-2$ } /**