mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Refactored timers example to use scheduling executor.
This commit is contained in:
parent
bc54ad145e
commit
3173aac06c
2 changed files with 11 additions and 3 deletions
|
@ -66,12 +66,20 @@ public class DefaultDsfExecutor extends ScheduledThreadPoolExecutor
|
||||||
if (r instanceof Future) {
|
if (r instanceof Future) {
|
||||||
Future future = (Future)r;
|
Future future = (Future)r;
|
||||||
try {
|
try {
|
||||||
future.get();
|
/*
|
||||||
|
* Try to retrieve the value, which should throw exception in
|
||||||
|
* case when exception was thrown within the Runnable/Callable.
|
||||||
|
* Must call isDone(), because scheduled futures would block
|
||||||
|
* on get.
|
||||||
|
*/
|
||||||
|
if (future.isDone()) {
|
||||||
|
future.get();
|
||||||
|
}
|
||||||
} catch (InterruptedException e) { // Ignore
|
} catch (InterruptedException e) { // Ignore
|
||||||
} catch (CancellationException e) { // Ignore also
|
} catch (CancellationException e) { // Ignore also
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
if (e.getCause() != null) {
|
if (e.getCause() != null) {
|
||||||
logException(t);
|
logException(e.getCause());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,7 +369,7 @@ abstract public class DsfSequence extends DsfRunnable implements Future<Object>
|
||||||
if (fRollbackTaskName != null) {
|
if (fRollbackTaskName != null) {
|
||||||
fProgressMonitor.subTask(fRollbackTaskName);
|
fProgressMonitor.subTask(fRollbackTaskName);
|
||||||
}
|
}
|
||||||
fStatus = new Status(IStatus.CANCEL, DsfPlugin.PLUGIN_ID, "Sequence \"" + fTaskName + "\" cancelled.");
|
fStatus = new Status(IStatus.CANCEL, DsfPlugin.PLUGIN_ID, -1, "Sequence \"" + fTaskName + "\" cancelled.", null);
|
||||||
if (fDone != null) {
|
if (fDone != null) {
|
||||||
fDone.setStatus(fStatus);
|
fDone.setStatus(fStatus);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue