Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tm.te.core')
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.core/META-INF/MANIFEST.MF2
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AbstractAsyncExecutableJob.java14
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AbstractAsyncExecutableStepperJob.java (renamed from target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AsyncExecutableStepperJob.java)6
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AsyncCallbackCollector.java29
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AsyncCallbackHandler.java30
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/model/ThreadSafeContainerModelNode.java28
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/model/ThreadSafeModelNode.java28
7 files changed, 49 insertions, 88 deletions
diff --git a/target_explorer/plugins/org.eclipse.tm.te.core/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tm.te.core/META-INF/MANIFEST.MF
index 015f2121f..a9dd00f75 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.core/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tm.te.core/META-INF/MANIFEST.MF
@@ -7,7 +7,6 @@ Bundle-Activator: org.eclipse.tm.te.core.activator.CoreBundleActivator
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0",
org.eclipse.tm.te.runtime;bundle-version="1.0.0",
- org.eclipse.tm.te.runtime.concurrent;bundle-version="1.0.0",
org.eclipse.tm.te.runtime.stepper;bundle-version="1.0.0",
org.eclipse.tm.te.runtime.services;bundle-version="1.0.0",
org.eclipse.tm.te.runtime.persistence;bundle-version="1.0.0",
@@ -23,7 +22,6 @@ Export-Package: org.eclipse.tm.te.core.activator;x-internal:=true,
org.eclipse.tm.te.core.connection.interfaces,
org.eclipse.tm.te.core.connection.managers,
org.eclipse.tm.te.core.connection.strategy,
- org.eclipse.tm.te.core.model,
org.eclipse.tm.te.core.model.interfaces,
org.eclipse.tm.te.core.nls;x-internal:=true,
org.eclipse.tm.te.core.utils.text
diff --git a/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AbstractAsyncExecutableJob.java b/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AbstractAsyncExecutableJob.java
index c6b2536aa..4abd2a781 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AbstractAsyncExecutableJob.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AbstractAsyncExecutableJob.java
@@ -17,7 +17,7 @@ import org.eclipse.core.runtime.jobs.IJobManager;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.tm.te.core.async.interfaces.IAsyncExecutable;
import org.eclipse.tm.te.runtime.callback.Callback;
-import org.eclipse.tm.te.runtime.concurrent.util.ExecutorsUtil;
+import org.eclipse.tm.te.runtime.interfaces.IConditionTester;
import org.eclipse.tm.te.runtime.interfaces.callback.ICallback;
import org.eclipse.tm.te.runtime.utils.ProgressHelper;
@@ -186,6 +186,16 @@ public abstract class AbstractAsyncExecutableJob extends Job implements IAsyncEx
*/
protected abstract void internalExecute(final IProgressMonitor monitor, final ICallback callback);
+ /**
+ * Hold the execution of {@link #run(IProgressMonitor)} until the asynchronous executable
+ * has completed the execution and invoked the callback.
+ *
+ * @param timeout The timeout in milliseconds. <code>0</code> means wait forever.
+ * @param conditionTester The condition tester which condition must be fulfilled until
+ * the execution hold of {@link #run(IProgressMonitor)} can be released.
+ */
+ protected abstract void waitAndExecute(long timeout, IConditionTester conditionTester);
+
/* (non-Javadoc)
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
*/
@@ -196,7 +206,7 @@ public abstract class AbstractAsyncExecutableJob extends Job implements IAsyncEx
ProgressHelper.beginTask(monitor, "", jobTicks); //$NON-NLS-1$
final Callback callback = new Callback(monitor, ProgressHelper.PROGRESS_DONE, getJobCallback());
internalExecute(monitor, callback);
- ExecutorsUtil.waitAndExecute(0, callback.getDoneConditionTester(isCancelable() ? monitor : null));
+ waitAndExecute(0, callback.getDoneConditionTester(isCancelable() ? monitor : null));
finished = true;
if (getRescheduleDelay() >= 0 && Platform.isRunning() && (!isCancelable() || !monitor.isCanceled())) {
diff --git a/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AsyncExecutableStepperJob.java b/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AbstractAsyncExecutableStepperJob.java
index 073fd5cd4..0c12489cf 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AsyncExecutableStepperJob.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AbstractAsyncExecutableStepperJob.java
@@ -19,12 +19,12 @@ import org.eclipse.tm.te.runtime.interfaces.callback.ICallback;
import org.eclipse.tm.te.runtime.utils.ProgressHelper;
/**
- * Asynchronous executable stepper job.
+ * Abstract asynchronous executable stepper job.
* <p>
* The job executes a list of actions. If any action returns with an error, the whole job will be
* aborted.
*/
-public class AsyncExecutableStepperJob extends AbstractAsyncExecutableJob {
+public abstract class AbstractAsyncExecutableStepperJob extends AbstractAsyncExecutableJob {
private final IAsyncExecutable[] actions;
/**
@@ -33,7 +33,7 @@ public class AsyncExecutableStepperJob extends AbstractAsyncExecutableJob {
* @param name The job name. Must not be <code>null</code>
* @param actions The actions to execute. Must not be <code>null</code>.
*/
- public AsyncExecutableStepperJob(String name, IAsyncExecutable[] actions) {
+ public AbstractAsyncExecutableStepperJob(String name, IAsyncExecutable[] actions) {
super(name);
Assert.isNotNull(actions);
diff --git a/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AsyncCallbackCollector.java b/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AsyncCallbackCollector.java
index 92d171073..f0fb15908 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AsyncCallbackCollector.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AsyncCallbackCollector.java
@@ -17,7 +17,6 @@ import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.tm.te.core.activator.CoreBundleActivator;
import org.eclipse.tm.te.runtime.callback.Callback;
-import org.eclipse.tm.te.runtime.concurrent.util.ExecutorsUtil;
import org.eclipse.tm.te.runtime.interfaces.callback.ICallback;
/**
@@ -40,6 +39,23 @@ public class AsyncCallbackCollector extends AsyncCallbackHandler {
private boolean isFinished;
private boolean initDone;
+ // The reference to the callback invocation delegate
+ private ICallbackInvocationDelegate delegate = null;
+
+ /**
+ * Delegation interfaces used by the asynchronous callback collector to
+ * invoke the final callback.
+ */
+ public static interface ICallbackInvocationDelegate {
+
+ /**
+ * Invokes the given runnable.
+ *
+ * @param runnable The runnable. Must not be <code>null</code>.
+ */
+ public void invoke(Runnable runnable);
+ }
+
/**
* Simple target callback handling an asynchronous callback collector parent itself and remove
* themselves from the collector after callback has done.
@@ -90,21 +106,25 @@ public class AsyncCallbackCollector extends AsyncCallbackHandler {
* Constructor.
*/
public AsyncCallbackCollector() {
- this(null);
+ this(null, null);
}
/**
* Constructor.
*
* @param callback The final callback to invoke if the collector enters the finished state.
+ * @param delegate The callback invocation delegate. Must not be <code>null</code> if the callback is not <code>null</code>.
*/
- public AsyncCallbackCollector(ICallback callback) {
+ public AsyncCallbackCollector(ICallback callback, ICallbackInvocationDelegate delegate) {
super();
+ if (callback != null) Assert.isNotNull(delegate);
+
// We have to add our master callback to the list of callback to avoid that
// the collector is running empty to early!
addCallback(callback);
this.callback = callback;
+ this.delegate = delegate;
// We are not finished yet.
isFinished = false;
@@ -141,7 +161,8 @@ public class AsyncCallbackCollector extends AsyncCallbackHandler {
*/
protected void onCollectorFinished() {
if (callback != null) {
- ExecutorsUtil.execute(new Runnable() {
+ Assert.isNotNull(delegate);
+ delegate.invoke(new Runnable() {
@Override
public void run() {
Throwable error = getError();
diff --git a/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AsyncCallbackHandler.java b/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AsyncCallbackHandler.java
index f854ec591..8ea299ebc 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AsyncCallbackHandler.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/async/AsyncCallbackHandler.java
@@ -16,7 +16,6 @@ import java.util.Map;
import java.util.Vector;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.tm.te.runtime.concurrent.util.ExecutorsUtil;
import org.eclipse.tm.te.runtime.interfaces.IConditionTester;
import org.eclipse.tm.te.runtime.interfaces.callback.ICallback;
@@ -26,7 +25,6 @@ import org.eclipse.tm.te.runtime.interfaces.callback.ICallback;
public class AsyncCallbackHandler {
private final List<ICallback> callbacks = new Vector<ICallback>();
private final IConditionTester conditionTester;
- private boolean timeoutOccurred;
private Throwable error;
private final static boolean TRACING_ENABLED = Boolean.parseBoolean(Platform.getDebugOption("org.eclipse.tm.te.runtime/trace/callbacks")); //$NON-NLS-1$
@@ -47,7 +45,6 @@ public class AsyncCallbackHandler {
*/
public AsyncCallbackHandler(IConditionTester tester) {
super();
- timeoutOccurred = false;
error = null;
conditionTester = new AsyncCallbackConditionTester(tester);
}
@@ -147,11 +144,14 @@ public class AsyncCallbackHandler {
}
/**
- * Returns <code>true</code> if the <code>wait</code> methods have been left because of timeout
- * and not because the waiting condition has been fulfilled.
+ * Returns the condition tester to use for waiting for the callback handler
+ * until all callbacks have been invoked and the external condition tester
+ * is fulfilled too.
+ *
+ * @return The condition tester instance.
*/
- public boolean isTimeoutOccurred() {
- return timeoutOccurred;
+ public IConditionTester getConditionTester() {
+ return conditionTester;
}
final class AsyncCallbackConditionTester implements IConditionTester {
@@ -170,8 +170,7 @@ public class AsyncCallbackHandler {
externalTester = tester;
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.tm.te.runtime.interfaces.IConditionTester#cleanup()
*/
@Override
@@ -181,8 +180,7 @@ public class AsyncCallbackHandler {
}
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.tm.te.runtime.interfaces.IConditionTester#isConditionFulfilled()
*/
@Override
@@ -191,14 +189,4 @@ public class AsyncCallbackHandler {
return isEmpty() || (externalTester != null && externalTester.isConditionFulfilled());
}
}
-
- /**
- * Wait for all associated callback's to finish or the specified timeout has been occurred.
- *
- * @param timeout The timeout in milliseconds. If <code>0</code>, the method waits forever till
- * all callback's have been returned.
- */
- public final void waitForFinishOrTimeout(long timeout) {
- timeoutOccurred = ExecutorsUtil.waitAndExecute(timeout, conditionTester);
- }
}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/model/ThreadSafeContainerModelNode.java b/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/model/ThreadSafeContainerModelNode.java
deleted file mode 100644
index 73fe10a67..000000000
--- a/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/model/ThreadSafeContainerModelNode.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Wind River Systems, Inc. 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.tm.te.core.model;
-
-import org.eclipse.tm.te.runtime.concurrent.util.ExecutorsUtil;
-import org.eclipse.tm.te.runtime.model.ContainerModelNode;
-
-/**
- * Container model node implementation assuring thread safety by enforcing model operations to
- * happen in the executor thread.
- */
-public class ThreadSafeContainerModelNode extends ContainerModelNode {
-
- /* (non-Javadoc)
- * @see org.eclipse.tm.te.runtime.nodes.PropertiesContainer#checkThreadAccess()
- */
- @Override
- protected boolean checkThreadAccess() {
- return ExecutorsUtil.isExecutorThread();
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/model/ThreadSafeModelNode.java b/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/model/ThreadSafeModelNode.java
deleted file mode 100644
index 357405372..000000000
--- a/target_explorer/plugins/org.eclipse.tm.te.core/src/org/eclipse/tm/te/core/model/ThreadSafeModelNode.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Wind River Systems, Inc. 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.tm.te.core.model;
-
-import org.eclipse.tm.te.runtime.concurrent.util.ExecutorsUtil;
-import org.eclipse.tm.te.runtime.model.ModelNode;
-
-/**
- * Model node implementation assuring thread safety by enforcing model operations to happen in the
- * executor thread.
- */
-public class ThreadSafeModelNode extends ModelNode {
-
- /* (non-Javadoc)
- * @see org.eclipse.tm.te.runtime.nodes.PropertiesContainer#checkThreadAccess()
- */
- @Override
- protected boolean checkThreadAccess() {
- return ExecutorsUtil.isExecutorThread();
- }
-}

Back to the top