mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
[211523] Added an ImmediateExecutor implementation.
This commit is contained in:
parent
a3649d568b
commit
0c476c0d38
3 changed files with 33 additions and 9 deletions
|
@ -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 <code>RequestMonitor</code>
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,7 +12,6 @@ package org.eclipse.dd.dsf.concurrent;
|
||||||
|
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
@ -112,13 +111,7 @@ abstract public class Query<V> extends DsfRunnable
|
||||||
* shut down. In that case, the DSF executor may throw a
|
* shut down. In that case, the DSF executor may throw a
|
||||||
* RejectedExecutionException which would have to be handled by the query.
|
* RejectedExecutionException which would have to be handled by the query.
|
||||||
*/
|
*/
|
||||||
Executor rmExecutor = new Executor() {
|
execute(new DataRequestMonitor<V>(ImmediateExecutor.getInstance(), null) {
|
||||||
public void execute(Runnable command) {
|
|
||||||
command.run();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
execute(new DataRequestMonitor<V>(rmExecutor, null) {
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCompleted() {
|
public void handleCompleted() {
|
||||||
if (getStatus().isOK()) fSync.doSet(getData());
|
if (getStatus().isOK()) fSync.doSet(getData());
|
||||||
|
|
|
@ -159,7 +159,7 @@ public class RequestMonitor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "RequestMonitor: " + getStatus().toString(); //$NON-NLS-1$
|
return "RequestMonitor (" + super.toString() + "): " + getStatus().toString(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue