1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 352888: Add two new "done" methods to RequestMonitor and DataRequestMonitor

This commit is contained in:
Eugene Ostroukhov 2011-08-30 15:20:25 -04:00 committed by Marc Khouzam
parent a8522bf2a1
commit 97d0869a9a
4 changed files with 51 additions and 8 deletions

View file

@ -566,11 +566,10 @@ public class SyncUtil {
Assert.assertEquals("unexpected number of processes", 1, contexts.length);
IDMContext context = contexts[0];
Assert.assertNotNull("unexpected process context type ", context);
rm.setData((IContainerDMContext)context);
rm.done((IContainerDMContext)context);
} else {
rm.setStatus(getStatus());
rm.done(getStatus());
}
rm.done();
}
});
}

View file

@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.cdt.dsf;singleton:=true
Bundle-Version: 2.2.0.qualifier
Bundle-Version: 2.3.0.qualifier
Bundle-Activator: org.eclipse.cdt.dsf.internal.DsfPlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,

View file

@ -7,6 +7,7 @@
*
* Contributors:
* Wind River Systems - initial API and implementation
* Eugene Ostroukhov (NVIDIA) - new done(V) method
*******************************************************************************/
package org.eclipse.cdt.dsf.concurrent;
@ -33,6 +34,8 @@ public class DataRequestMonitor<V> extends RequestMonitor {
* Sets the data object to specified value. To be called by the
* asynchronous method implementor.
* @param data Data value to set.
*
* @see #done(Object)
*/
public synchronized void setData(V data) { fData = data; }
@ -41,6 +44,26 @@ public class DataRequestMonitor<V> extends RequestMonitor {
*/
public synchronized V getData() { return fData; }
/**
* Completes the monitor setting data object to specified value. To be
* called by asynchronous method implementor.
*
* <p>
* Note: Only one <code>done</code> method should be called and only once,
* for every request issued. Even if the request was canceled.
* </p>
*
* @param data Data value to set
* @see #setData(Object)
* @see #done()
* @see #done(org.eclipse.core.runtime.IStatus)
* @since 2.3
*/
public synchronized void done(V data) {
setData(data);
done();
}
@Override
public String toString() {
if (getData() != null) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2010 Wind River Systems and others.
* Copyright (c) 2006, 2011 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
@ -7,6 +7,7 @@
*
* Contributors:
* Wind River Systems - initial API and implementation
* Eugene Ostroukhov (NVIDIA) - new done(IStatus) method
*******************************************************************************/
package org.eclipse.cdt.dsf.concurrent;
@ -165,7 +166,9 @@ public class RequestMonitor extends DsfExecutable {
/**
* Sets the status of the result of the request. If status is OK, this
* method does not need to be called.
* method does not need to be called.
*
* @see #done(IStatus)
*/
public synchronized void setStatus(IStatus status) {
assert isCanceled() || status.getSeverity() != IStatus.CANCEL;
@ -270,8 +273,8 @@ public class RequestMonitor extends DsfExecutable {
* monitor submits a runnable to the DSF Executor to call the
* <code>handle...</code> methods.
* <p>
* Note: This method should be called once and only once, for every request
* issued. Even if the request was canceled.
* Note: Only one <code>done</code> method should be called and only once,
* for every request issued. Even if the request was canceled.
* </p>
*/
public synchronized void done() {
@ -306,6 +309,24 @@ public class RequestMonitor extends DsfExecutable {
handleRejectedExecutionException();
}
}
/**
* Sets status and marks request monitor as completed.
*
* <p>
* Note: Only one <code>done</code> method should be called and only once,
* for every request issued. Even if the request was canceled.
* </p>
*
* @param status Request processing status
* @see #done()
* @see #setStatus(IStatus)
* @since 2.3
*/
public synchronized void done(IStatus status) {
setStatus(status);
done();
}
@Override
public String toString() {