mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-14 20:45:22 +02:00
[216252] canceled --> cancelled in comments
This commit is contained in:
parent
a2a2105997
commit
71fbaa7e47
2 changed files with 51 additions and 51 deletions
|
@ -32,33 +32,33 @@ import org.eclipse.rse.core.RSECorePlugin;
|
||||||
import org.eclipse.rse.logging.Logger;
|
import org.eclipse.rse.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a job named "Initialize RSE". It is instantiated and run during
|
* This is a job named "Initialize RSE". It is instantiated and run during
|
||||||
* RSE startup. It must not be run at any other time. The job restores the
|
* RSE startup. It must not be run at any other time. The job restores the
|
||||||
* persistent form of the RSE model. Use the extension point
|
* persistent form of the RSE model. Use the extension point
|
||||||
* org.eclipse.rse.core.modelInitializers to supplement the model once it is
|
* org.eclipse.rse.core.modelInitializers to supplement the model once it is
|
||||||
* restored.
|
* restored.
|
||||||
*/
|
*/
|
||||||
public final class RSEInitJob extends Job {
|
public final class RSEInitJob extends Job {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of this job. This is API. Clients may use this name to find this job by name.
|
* The name of this job. This is API. Clients may use this name to find this job by name.
|
||||||
*/
|
*/
|
||||||
public final static String NAME = "Initialize RSE"; //$NON-NLS-1$
|
public final static String NAME = "Initialize RSE"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static RSEInitJob instance = new RSEInitJob();
|
private static RSEInitJob instance = new RSEInitJob();
|
||||||
|
|
||||||
private class Phase {
|
private class Phase {
|
||||||
private volatile boolean isCanceled = false;
|
private volatile boolean isCancelled = false;
|
||||||
private volatile boolean isComplete = false;
|
private volatile boolean isComplete = false;
|
||||||
private int phaseNumber = 0;
|
private int phaseNumber = 0;
|
||||||
public Phase(int phaseNumber) {
|
public Phase(int phaseNumber) {
|
||||||
this.phaseNumber = phaseNumber;
|
this.phaseNumber = phaseNumber;
|
||||||
}
|
}
|
||||||
public synchronized void waitForCompletion() throws InterruptedException {
|
public synchronized void waitForCompletion() throws InterruptedException {
|
||||||
while (!isComplete && !isCanceled) {
|
while (!isComplete && !isCancelled) {
|
||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
if (isCanceled) {
|
if (isCancelled) {
|
||||||
throw new InterruptedException();
|
throw new InterruptedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,14 +70,14 @@ public final class RSEInitJob extends Job {
|
||||||
notifyListeners(phaseNumber);
|
notifyListeners(phaseNumber);
|
||||||
}
|
}
|
||||||
public synchronized void cancel() {
|
public synchronized void cancel() {
|
||||||
isCanceled = true;
|
isCancelled = true;
|
||||||
notifyAll();
|
notifyAll();
|
||||||
}
|
}
|
||||||
public boolean isComplete() {
|
public boolean isComplete() {
|
||||||
return isComplete;
|
return isComplete;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MyJobChangeListener implements IJobChangeListener {
|
private class MyJobChangeListener implements IJobChangeListener {
|
||||||
public void aboutToRun(IJobChangeEvent event) {
|
public void aboutToRun(IJobChangeEvent event) {
|
||||||
}
|
}
|
||||||
|
@ -100,15 +100,15 @@ public final class RSEInitJob extends Job {
|
||||||
public void sleeping(IJobChangeEvent event) {
|
public void sleeping(IJobChangeEvent event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Phase finalPhase = new Phase(RSECorePlugin.INIT_ALL);
|
private Phase finalPhase = new Phase(RSECorePlugin.INIT_ALL);
|
||||||
private Phase modelPhase = new Phase(RSECorePlugin.INIT_MODEL);
|
private Phase modelPhase = new Phase(RSECorePlugin.INIT_MODEL);
|
||||||
private Phase initializerPhase = new Phase(RSECorePlugin.INIT_INITIALIZER);
|
private Phase initializerPhase = new Phase(RSECorePlugin.INIT_INITIALIZER);
|
||||||
private List listeners = new ArrayList(10);
|
private List listeners = new ArrayList(10);
|
||||||
private Logger logger = RSECorePlugin.getDefault().getLogger();
|
private Logger logger = RSECorePlugin.getDefault().getLogger();
|
||||||
private MyJobChangeListener myJobChangeListener = new MyJobChangeListener();
|
private MyJobChangeListener myJobChangeListener = new MyJobChangeListener();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the singleton instance of this job.
|
* Returns the singleton instance of this job.
|
||||||
* @return the InitRSEJob instance for this workbench.
|
* @return the InitRSEJob instance for this workbench.
|
||||||
|
@ -116,12 +116,12 @@ public final class RSEInitJob extends Job {
|
||||||
public static RSEInitJob getInstance() {
|
public static RSEInitJob getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private RSEInitJob() {
|
private RSEInitJob() {
|
||||||
super(NAME);
|
super(NAME);
|
||||||
addJobChangeListener(myJobChangeListener);
|
addJobChangeListener(myJobChangeListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new listener to the set of listeners to be notified when initialization phases complete.
|
* Adds a new listener to the set of listeners to be notified when initialization phases complete.
|
||||||
* If the listener is added after the phase has completed it will not be invoked.
|
* If the listener is added after the phase has completed it will not be invoked.
|
||||||
|
@ -134,7 +134,7 @@ public final class RSEInitJob extends Job {
|
||||||
listeners.add(listener);
|
listeners.add(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a listener to the set of listeners to be notified when phases complete.
|
* Removes a listener to the set of listeners to be notified when phases complete.
|
||||||
* If the listener is not in the set this does nothing.
|
* If the listener is not in the set this does nothing.
|
||||||
|
@ -145,7 +145,7 @@ public final class RSEInitJob extends Job {
|
||||||
listeners.remove(listener);
|
listeners.remove(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify all registered listeners of a phase completion
|
* Notify all registered listeners of a phase completion
|
||||||
* @param phase the phase just completed.
|
* @param phase the phase just completed.
|
||||||
|
@ -164,7 +164,7 @@ public final class RSEInitJob extends Job {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
|
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
|
@ -175,7 +175,7 @@ public final class RSEInitJob extends Job {
|
||||||
modelPhase.done();
|
modelPhase.done();
|
||||||
// instantiate and run initializers
|
// instantiate and run initializers
|
||||||
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.rse.core.modelInitializers"); //$NON-NLS-1$
|
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.rse.core.modelInitializers"); //$NON-NLS-1$
|
||||||
monitor.beginTask(RSECoreMessages.InitRSEJob_initializing_rse, elements.length);
|
monitor.beginTask(RSECoreMessages.InitRSEJob_initializing_rse, elements.length);
|
||||||
for (int i = 0; i < elements.length && !monitor.isCanceled(); i++) {
|
for (int i = 0; i < elements.length && !monitor.isCanceled(); i++) {
|
||||||
IConfigurationElement element = elements[i];
|
IConfigurationElement element = elements[i];
|
||||||
IProgressMonitor submonitor = new SubProgressMonitor(monitor, 1);
|
IProgressMonitor submonitor = new SubProgressMonitor(monitor, 1);
|
||||||
|
@ -203,7 +203,7 @@ public final class RSEInitJob extends Job {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a handle to a mark file based on the initializer class name.
|
* Returns a handle to a mark file based on the initializer class name.
|
||||||
* @param element the element that defines the initializer
|
* @param element the element that defines the initializer
|
||||||
|
@ -218,7 +218,7 @@ public final class RSEInitJob extends Job {
|
||||||
File markFile = new File(markPath.toOSString());
|
File markFile = new File(markPath.toOSString());
|
||||||
return markFile;
|
return markFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param element the element to test for marking
|
* @param element the element to test for marking
|
||||||
* @return true if the element is marked
|
* @return true if the element is marked
|
||||||
|
@ -227,7 +227,7 @@ public final class RSEInitJob extends Job {
|
||||||
File markFile = getMarkFile(element);
|
File markFile = getMarkFile(element);
|
||||||
return markFile.exists();
|
return markFile.exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param element the element to mark
|
* @param element the element to mark
|
||||||
* @return a status indicating if the marking was successful
|
* @return a status indicating if the marking was successful
|
||||||
|
@ -261,18 +261,18 @@ public final class RSEInitJob extends Job {
|
||||||
try {
|
try {
|
||||||
status = initializer.run(submonitor);
|
status = initializer.run(submonitor);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
String message = NLS.bind(RSECoreMessages.InitRSEJob_initializer_ended_in_error, initializerName);
|
String message = NLS.bind(RSECoreMessages.InitRSEJob_initializer_ended_in_error, initializerName);
|
||||||
logger.logError(message, e);
|
logger.logError(message, e);
|
||||||
status = new Status(IStatus.ERROR, RSECorePlugin.PLUGIN_ID, message, e);
|
status = new Status(IStatus.ERROR, RSECorePlugin.PLUGIN_ID, message, e);
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
String message = NLS.bind(RSECoreMessages.InitRSEJob_initializer_failed_to_load, initializerName);
|
String message = NLS.bind(RSECoreMessages.InitRSEJob_initializer_failed_to_load, initializerName);
|
||||||
logger.logError(message, e);
|
logger.logError(message, e);
|
||||||
status = new Status(IStatus.ERROR, RSECorePlugin.PLUGIN_ID, message, e);
|
status = new Status(IStatus.ERROR, RSECorePlugin.PLUGIN_ID, message, e);
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Waits until a job is completed.
|
* Waits until a job is completed.
|
||||||
* @return the status of the job upon its completion.
|
* @return the status of the job upon its completion.
|
||||||
|
@ -307,7 +307,7 @@ public final class RSEInitJob extends Job {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param phase the phase for which completion is requested.
|
* @param phase the phase for which completion is requested.
|
||||||
* Phases are defined in {@link RSECorePlugin}.
|
* Phases are defined in {@link RSECorePlugin}.
|
||||||
* @return true if this phase has completed.
|
* @return true if this phase has completed.
|
||||||
* @throws IllegalArgumentException if the phase is undefined.
|
* @throws IllegalArgumentException if the phase is undefined.
|
||||||
|
@ -332,5 +332,5 @@ public final class RSEInitJob extends Job {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 Wind River Systems, Inc.
|
* Copyright (c) 2006 Wind River Systems, Inc.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Martin Oberhuber (Wind River) - initial API and implementation
|
* Martin Oberhuber (Wind River) - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.services;
|
package org.eclipse.rse.services;
|
||||||
|
@ -23,7 +23,7 @@ import org.eclipse.rse.internal.services.Activator;
|
||||||
* A Mutual Exclusion Lock for Threads that need to access a resource
|
* A Mutual Exclusion Lock for Threads that need to access a resource
|
||||||
* in a serialized manner. An Eclipse ProgressMonitor is accepted
|
* in a serialized manner. An Eclipse ProgressMonitor is accepted
|
||||||
* in order to support cancellation when waiting for the Mutex.
|
* in order to support cancellation when waiting for the Mutex.
|
||||||
*
|
*
|
||||||
* Usage Example:
|
* Usage Example:
|
||||||
* <code>
|
* <code>
|
||||||
* private Mutex fooMutex = new Mutex();
|
* private Mutex fooMutex = new Mutex();
|
||||||
|
@ -38,12 +38,12 @@ import org.eclipse.rse.internal.services.Activator;
|
||||||
* return false;
|
* return false;
|
||||||
* }
|
* }
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* The Mutex is not reentrant, so when a Thread has locked the
|
* The Mutex is not reentrant, so when a Thread has locked the
|
||||||
* Mutex it must not try locking it again.
|
* Mutex it must not try locking it again.
|
||||||
*/
|
*/
|
||||||
public class Mutex {
|
public class Mutex {
|
||||||
|
|
||||||
private boolean fLocked = false;
|
private boolean fLocked = false;
|
||||||
private List fWaitQueue = new LinkedList();
|
private List fWaitQueue = new LinkedList();
|
||||||
|
|
||||||
|
@ -52,15 +52,15 @@ public class Mutex {
|
||||||
*/
|
*/
|
||||||
public Mutex() {
|
public Mutex() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to acquire the lock maintained by this mutex.
|
* Try to acquire the lock maintained by this mutex.
|
||||||
*
|
*
|
||||||
* If the thread needs to wait before it can acquire the mutex, it
|
* If the thread needs to wait before it can acquire the mutex, it
|
||||||
* will wait in a first-come-first-serve fashion. In case a progress
|
* will wait in a first-come-first-serve fashion. In case a progress
|
||||||
* monitor was given, it will be updated and checked for cancel every
|
* monitor was given, it will be updated and checked for cancel every
|
||||||
* second.
|
* second.
|
||||||
*
|
*
|
||||||
* @param monitor Eclipse Progress Monitor. May be <code>null</code>.
|
* @param monitor Eclipse Progress Monitor. May be <code>null</code>.
|
||||||
* @param timeout Maximum wait time given in milliseconds.
|
* @param timeout Maximum wait time given in milliseconds.
|
||||||
* @return <code>true</code> if the lock was obtained successfully.
|
* @return <code>true</code> if the lock was obtained successfully.
|
||||||
|
@ -90,8 +90,8 @@ public class Mutex {
|
||||||
long timeLeft = timeout;
|
long timeLeft = timeout;
|
||||||
long pollTime = (monitor!=null) ? 1000 : timeLeft;
|
long pollTime = (monitor!=null) ? 1000 : timeLeft;
|
||||||
long nextProgressUpdate = start+500;
|
long nextProgressUpdate = start+500;
|
||||||
boolean canceled = false;
|
boolean cancelled = false;
|
||||||
while (timeLeft>0 && !canceled && !lockAcquired) {
|
while (timeLeft > 0 && !cancelled && !lockAcquired) {
|
||||||
//is it my turn yet? Check wait queue and wait
|
//is it my turn yet? Check wait queue and wait
|
||||||
synchronized(fWaitQueue) {
|
synchronized(fWaitQueue) {
|
||||||
if (!fLocked && fWaitQueue.get(0) == myself) {
|
if (!fLocked && fWaitQueue.get(0) == myself) {
|
||||||
|
@ -115,8 +115,8 @@ public class Mutex {
|
||||||
long curTime = System.currentTimeMillis();
|
long curTime = System.currentTimeMillis();
|
||||||
timeLeft = start + timeout - curTime;
|
timeLeft = start + timeout - curTime;
|
||||||
if (monitor!=null) {
|
if (monitor!=null) {
|
||||||
canceled = monitor.isCanceled();
|
cancelled = monitor.isCanceled();
|
||||||
if (!canceled && (curTime>nextProgressUpdate)) {
|
if (!cancelled && (curTime > nextProgressUpdate)) {
|
||||||
monitor.worked(1);
|
monitor.worked(1);
|
||||||
nextProgressUpdate+=1000;
|
nextProgressUpdate+=1000;
|
||||||
}
|
}
|
||||||
|
@ -138,8 +138,8 @@ public class Mutex {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Release this mutex's lock.
|
* Release this mutex's lock.
|
||||||
*
|
*
|
||||||
* May only be called by the same thread that originally acquired
|
* May only be called by the same thread that originally acquired
|
||||||
* the Mutex.
|
* the Mutex.
|
||||||
*/
|
*/
|
||||||
public void release() {
|
public void release() {
|
||||||
|
@ -162,12 +162,12 @@ public class Mutex {
|
||||||
return fLocked;
|
return fLocked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interrupt all threads waiting for the Lock, causing their
|
* Interrupt all threads waiting for the Lock, causing their
|
||||||
* {@link #waitForLock(IProgressMonitor, long)} method to return
|
* {@link #waitForLock(IProgressMonitor, long)} method to return
|
||||||
* <code>false</code>.
|
* <code>false</code>.
|
||||||
* This should be called if the resource that the Threads are
|
* This should be called if the resource that the Threads are
|
||||||
* contending for, becomes unavailable for some other reason.
|
* contending for, becomes unavailable for some other reason.
|
||||||
*/
|
*/
|
||||||
public void interruptAll() {
|
public void interruptAll() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue