mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Converted DsfQuery to use generics.
This commit is contained in:
parent
0b17595f4e
commit
98268e2101
1 changed files with 8 additions and 8 deletions
|
@ -27,9 +27,9 @@ import org.eclipse.dd.dsf.DsfPlugin;
|
||||||
* @see java.util.concurrent.Callable
|
* @see java.util.concurrent.Callable
|
||||||
* FIXME: make this class implement the Future<V> interface.
|
* FIXME: make this class implement the Future<V> interface.
|
||||||
*/
|
*/
|
||||||
abstract public class DsfQuery {
|
abstract public class DsfQuery<V> {
|
||||||
|
|
||||||
private Object fResult;
|
private V fResult;
|
||||||
private boolean fValid;
|
private boolean fValid;
|
||||||
private DsfExecutor fExecutor;
|
private DsfExecutor fExecutor;
|
||||||
private Future fFuture;
|
private Future fFuture;
|
||||||
|
@ -52,7 +52,7 @@ abstract public class DsfQuery {
|
||||||
* Allows deriving classes to implement their own snipped additional
|
* Allows deriving classes to implement their own snipped additional
|
||||||
* cancellation code.
|
* cancellation code.
|
||||||
*/
|
*/
|
||||||
protected void revokeChildren(Object result) {};
|
protected void revokeChildren(V result) {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get data associated with this proxy. This method is thread safe and
|
* Get data associated with this proxy. This method is thread safe and
|
||||||
|
@ -60,7 +60,7 @@ abstract public class DsfQuery {
|
||||||
* for commands to be processed on the dispatch thread, this methods itself
|
* for commands to be processed on the dispatch thread, this methods itself
|
||||||
* CANNOT be called on the dispatch thread.
|
* CANNOT be called on the dispatch thread.
|
||||||
*/
|
*/
|
||||||
public synchronized Object get() {
|
public synchronized V get() {
|
||||||
assert !fExecutor.isInExecutorThread();
|
assert !fExecutor.isInExecutorThread();
|
||||||
if(!fValid) {
|
if(!fValid) {
|
||||||
if (!fWaiting) {
|
if (!fWaiting) {
|
||||||
|
@ -97,8 +97,8 @@ abstract public class DsfQuery {
|
||||||
* Same as get(), but with code to automatically re-threw the exception if one
|
* Same as get(), but with code to automatically re-threw the exception if one
|
||||||
* was reported by the run() method.
|
* was reported by the run() method.
|
||||||
*/
|
*/
|
||||||
public Object getWithThrows() throws CoreException {
|
public V getWithThrows() throws CoreException {
|
||||||
Object retVal = get();
|
V retVal = get();
|
||||||
if (!getStatus().isOK()) {
|
if (!getStatus().isOK()) {
|
||||||
throw new CoreException(getStatus());
|
throw new CoreException(getStatus());
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ abstract public class DsfQuery {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Abort current operation and set proxy data to 'result' */
|
/** Abort current operation and set proxy data to 'result' */
|
||||||
public synchronized void cancel(Object newResult) {
|
public synchronized void cancel(V newResult) {
|
||||||
fResult = newResult;
|
fResult = newResult;
|
||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ abstract public class DsfQuery {
|
||||||
|
|
||||||
public boolean isValid() { return fValid; }
|
public boolean isValid() { return fValid; }
|
||||||
|
|
||||||
public synchronized void done(Object result) {
|
public synchronized void done(V result) {
|
||||||
// Valid could be true if request was cancelled while data was
|
// Valid could be true if request was cancelled while data was
|
||||||
// being retrieved, and then done() was called.
|
// being retrieved, and then done() was called.
|
||||||
if (fValid) return;
|
if (fValid) return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue