Skip to content

Commit

Permalink
Format java files in o.e.equinox.concurrent
Browse files Browse the repository at this point in the history
This was achieved by running:
eclipse -consolelog -nosplash -application org.eclipse.jdt.core.JavaCodeFormatter \
  -config .settings/org.eclipse.jdt.core.prefs . -data `mktemp -d`

Signed-off-by: Torbjörn SVENSSON <[email protected]>
  • Loading branch information
Torbjorn-Svensson authored and akurtakov committed Nov 3, 2023
1 parent 99ce69f commit 1abded4
Show file tree
Hide file tree
Showing 14 changed files with 135 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

/**
* Abstract implementation of {@link IExecutor} and {@link IRunnableExecutor}.
*
* @since 1.1
*
*/
Expand All @@ -32,21 +33,18 @@ public Object run(IProgressMonitor monitor) throws Exception {
}, null);
}

public abstract <ResultType> IFuture<ResultType> execute(
IProgressRunnable<? extends ResultType> runnable,
public abstract <ResultType> IFuture<ResultType> execute(IProgressRunnable<? extends ResultType> runnable,
IProgressMonitor monitor);

/**
* Create an {@link AbstractFuture} instance. Subclasses must override to
* define the concrete type of future to return from
* Create an {@link AbstractFuture} instance. Subclasses must override to define
* the concrete type of future to return from
* {@link #execute(IProgressRunnable, IProgressMonitor)}.
*
* @param progressMonitor
* any progress monitor to provide to the future upon
* construction. May be <code>null</code>.
* @param progressMonitor any progress monitor to provide to the future upon
* construction. May be <code>null</code>.
* @return the created future
*/
protected abstract AbstractFuture<?> createFuture(
IProgressMonitor progressMonitor);
protected abstract AbstractFuture<?> createFuture(IProgressMonitor progressMonitor);

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

/**
* Abstract implementation of {@link IFuture} and {@link ISafeProgressRunner}.
*
* @since 1.1
*/
public abstract class AbstractFuture<ResultType> implements
IFuture<ResultType>, ISafeProgressRunner {
public abstract class AbstractFuture<ResultType> implements IFuture<ResultType>, ISafeProgressRunner {

/**
* Returns <code>true</code> if this future has been previously canceled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
* @since 1.1
*/
@SuppressWarnings("rawtypes")
public abstract class AbstractListenableFuture extends AbstractFuture implements
IListenableFuture {
public abstract class AbstractListenableFuture extends AbstractFuture implements IListenableFuture {

public abstract void addListener(IProgressRunnable progressRunnable,
IExecutor executor);
public abstract void addListener(IProgressRunnable progressRunnable, IExecutor executor);

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* wrapper for potentially two progress monitors: one provided by the
* {@link IFuture} client in a method call, the other (a child progress monitor)
* provided by the IExecutor that creates the future instance.
*
* @since 1.1
*
*/
Expand All @@ -30,12 +31,11 @@ public class FutureProgressMonitor extends ProgressMonitorWrapper {
private Object lock = new Object();

/**
* Create a new progress monitor wrapping the given monitor. The nested
* monitor is the one exposed to clients of futures.
* Create a new progress monitor wrapping the given monitor. The nested monitor
* is the one exposed to clients of futures.
*
* @param progressMonitor
* the client-facing monitor used with a future. May be
* <code>null</code>.
* @param progressMonitor the client-facing monitor used with a future. May be
* <code>null</code>.
*
* @see #setChildProgressMonitor(IProgressMonitor)
*/
Expand Down Expand Up @@ -102,11 +102,10 @@ public void worked(int work) {
/**
* Set the client-facing progress monitor to the given value.
*
* @param value
* a second (child) monitor to report progress/take cancelation
* from. If the parent progress monitor has been previously
* canceled, the child progress monitor's setCanceled method will
* be called.
* @param value a second (child) monitor to report progress/take cancelation
* from. If the parent progress monitor has been previously
* canceled, the child progress monitor's setCanceled method will
* be called.
*/
public void setChildProgressMonitor(IProgressMonitor value) {
synchronized (lock) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,33 @@ public interface IExecutor {
* <p>
* Execute the given {@link IProgressRunnable} (i.e. call
* {@link IProgressRunnable#run(IProgressMonitor)}. Will return a non-
* <code>null</code> instance of {@link IFuture} that allows clients to
* inspect the state of the execution and retrieve any results via
* {@link IFuture#get()} or {@link IFuture#get(long)}.
* <code>null</code> instance of {@link IFuture} that allows clients to inspect
* the state of the execution and retrieve any results via {@link IFuture#get()}
* or {@link IFuture#get(long)}.
* </p>
* <p>
* Note that implementers may decide whether to invoke
* {@link IProgressRunnable#run(IProgressMonitor)} asynchronously or
* synchronously, but since IProgressRunnables are frequently going to be
* longer-running operations, implementers should proceed carefully before
* implementing with synchronous (blocking) invocation. Implementers should
* typically implement via some non-blocking asynchronous invocation
* mechanism, e.g. Threads, Jobs, ThreadPools etc.
* typically implement via some non-blocking asynchronous invocation mechanism,
* e.g. Threads, Jobs, ThreadPools etc.
* </p>
*
* @param runnable
* the {@link IProgressRunnable} to invoke. Must not be
* <code>null</code>.
* @param monitor
* any {@link IProgressMonitor} to be passed to the runnable. May
* be <code>null</code>.
* @param runnable the {@link IProgressRunnable} to invoke. Must not be
* <code>null</code>.
* @param monitor any {@link IProgressMonitor} to be passed to the runnable.
* May be <code>null</code>.
* @return {@link IFuture} to allow for inspection of the state of the
* computation by clients, as well as access to any return values of
* {@link IProgressRunnable#run(IProgressMonitor)}. Will not be
* <code>null</code>.
* @param <ResultType>
* the type that will be returned by the
* {@link IProgressRunnable} as well as the returned
* {@link IFuture}
* @param <ResultType> the type that will be returned by the
* {@link IProgressRunnable} as well as the returned
* {@link IFuture}
*/
<ResultType> IFuture<ResultType> execute(
IProgressRunnable<? extends ResultType> runnable,
<ResultType> IFuture<ResultType> execute(IProgressRunnable<? extends ResultType> runnable,
IProgressMonitor monitor);

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@
* </p>
*
* @see IStatus
* @param <ResultType>
* the type that will be returned by {@link #get()} and/or
* {@link #get(long)}
* @param <ResultType> the type that will be returned by {@link #get()} and/or
* {@link #get(long)}
* @since 1.1
*
*/
Expand All @@ -61,84 +60,78 @@ public interface IFuture<ResultType> {
* Cancel the operation
*
* @return <tt>false</tt> if the operation could not be canceled, typically
* because it has already completed normally; <tt>true</tt>
* otherwise
* because it has already completed normally; <tt>true</tt> otherwise
*/
public boolean cancel();

/**
* Waits if necessary for one or more operations to complete, and then
* returns result(s). This method will block until either a) at least one
* result is available; or b) at least one operation throws an exception.
* Waits if necessary for one or more operations to complete, and then returns
* result(s). This method will block until either a) at least one result is
* available; or b) at least one operation throws an exception.
*
* @return Object result of the asynchronous operation(s)
* @throws InterruptedException
* if thread calling this method is interrupted.
* @throws OperationCanceledException
* if the operation has been canceled via progress monitor
* {@link #getProgressMonitor()}.
* @throws InterruptedException if thread calling this method is
* interrupted.
* @throws OperationCanceledException if the operation has been canceled via
* progress monitor
* {@link #getProgressMonitor()}.
*/
ResultType get() throws InterruptedException, OperationCanceledException;

/**
* Waits if necessary for one or more operations to complete, and then
* returns result(s). This method will block until either a) at least one
* result is available; or b) at least one operation throws an exception.
* Waits if necessary for one or more operations to complete, and then returns
* result(s). This method will block until either a) at least one result is
* available; or b) at least one operation throws an exception.
*
* @param waitTimeInMillis
* the maximum time to wait in milliseconds for the operation(s)
* to complete.
* @param waitTimeInMillis the maximum time to wait in milliseconds for the
* operation(s) to complete.
* @return Object result of the asynchronous operation(s)
* @throws InterruptedException
* if thread calling this method is interrupted.
* @throws TimeoutException
* if the given wait time is exceeded without getting result.
* @throws OperationCanceledException
* if the operation has been canceled via progress monitor
* {@link #getProgressMonitor()}.
* @throws InterruptedException if thread calling this method is
* interrupted.
* @throws TimeoutException if the given wait time is exceeded without
* getting result.
* @throws OperationCanceledException if the operation has been canceled via
* progress monitor
* {@link #getProgressMonitor()}.
*/
ResultType get(long waitTimeInMillis) throws InterruptedException,
TimeoutException, OperationCanceledException;
ResultType get(long waitTimeInMillis) throws InterruptedException, TimeoutException, OperationCanceledException;

/**
* <p>
* Get status for operation. Will return <code>null</code> until at least
* one operation(s) are complete.
* Get status for operation. Will return <code>null</code> until at least one
* operation(s) are complete.
* </p>
* <p>
* If {@link #hasValue()} returns <code>true</code>, this method will return
* a non-<code>null</code> IStatus. If {@link #hasValue()} returns
* If {@link #hasValue()} returns <code>true</code>, this method will return a
* non-<code>null</code> IStatus. If {@link #hasValue()} returns
* <code>false</code>, this method will return <code>null</code>.
* </p>
* <p>
* Note that the returned IStatus instance may be an IMultiStatus, meaning
* that multiple operations have completed or are pending completion.
* Note that the returned IStatus instance may be an IMultiStatus, meaning that
* multiple operations have completed or are pending completion.
* </p>
*
* @return IStatus the status of completed operation(s). Will return
* <code>null</code> if {@link #hasValue()} returns
* <code>false</code>.
* <code>null</code> if {@link #hasValue()} returns <code>false</code>.
*
* @see #hasValue()
*/
public IStatus getStatus();

/**
* <p>
* Returns <tt>true</tt> if <b>any</b> underlying operation(s) have
* completed.
* Returns <tt>true</tt> if <b>any</b> underlying operation(s) have completed.
* </p>
* <p>
* If this future represents access to just one operation, then this method
* and {@link #isDone()} will always return the same value. That is, when a
* single operation has a value, it is then considered done/completed and
* both {@link #isDone()} and this method will return <code>true</code>.
* If this future represents access to just one operation, then this method and
* {@link #isDone()} will always return the same value. That is, when a single
* operation has a value, it is then considered done/completed and both
* {@link #isDone()} and this method will return <code>true</code>.
* </p>
* <p>
* If this future represents multiple operations, then this method will
* return <code>true</code> when <b>any</b> of the operations have
* completed. Until the first operation is completed, it will return
* <code>false</code>.
* If this future represents multiple operations, then this method will return
* <code>true</code> when <b>any</b> of the operations have completed. Until the
* first operation is completed, it will return <code>false</code>.
* </p>
*
* @return <tt>true</tt> if any operations represented by this future have
Expand All @@ -152,21 +145,20 @@ ResultType get(long waitTimeInMillis) throws InterruptedException,
* completed.
* </p>
* <p>
* If this future represents access to just one operation, then this method
* and {@link #hasValue()} will always return the same value. That is, when
* a single operation has a value, it is then considered done/completed and
* both {@link #hasValue()} and #isDone will return <code>true</code>.
* If this future represents access to just one operation, then this method and
* {@link #hasValue()} will always return the same value. That is, when a single
* operation has a value, it is then considered done/completed and both
* {@link #hasValue()} and #isDone will return <code>true</code>.
* </p>
* <p>
* If this future represents multiple operations, then this method will only
* return <code>true</code> when <b>all</b> of the operations have
* completed. Until all operations have completed, it will return
* <code>false</code>.
* return <code>true</code> when <b>all</b> of the operations have completed.
* Until all operations have completed, it will return <code>false</code>.
* </p>
* <p>
* Completion can be due to normal operation completion, an exception, or
* user cancellation -- in all of these cases, this method will return
* <tt>true</tt> if all underlying operation(s) have been completed.
* Completion can be due to normal operation completion, an exception, or user
* cancellation -- in all of these cases, this method will return <tt>true</tt>
* if all underlying operation(s) have been completed.
* </p>
*
* @return <tt>true</tt> if all operation(s) have completed in some manner.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*
* A future that allows for an {@link IProgressRunnable} (with optional
* {@link IProgressMonitor}) to be executed via an {@link IExecutor}.
*
* @since 1.1
*
*/
Expand All @@ -30,22 +31,21 @@ public interface IListenableFuture<ResultType> extends IFuture<ResultType> {
* non-<code>null</code> and the {@link IExecutor} must also be non-
* <code>null</code>. The given progressMonitor may be <code>null</code>.
* <p>
* If the future has already completed by the time this method is called
* (i.e. {@link #isDone()} returns <code>true</code>, the progressRunnable
* will be executed immediately by the given executor.
* If the future has already completed by the time this method is called (i.e.
* {@link #isDone()} returns <code>true</code>, the progressRunnable will be
* executed immediately by the given executor.
*
* @param executor
* the {@link IExecutor} to use to execute the given
* {@link IProgressRunnable}. Must not be <code>null</code>.
* @param progressRunnable
* the {@link IProgressRunnable} that will be executed when this
* future is complete. Must not be <code>null</code>.
* @param monitor
* an optional progress monitor to be passed to the
* progressRunnable when executed. May be <code>null</code>.
* @param executor the {@link IExecutor} to use to execute the given
* {@link IProgressRunnable}. Must not be
* <code>null</code>.
* @param progressRunnable the {@link IProgressRunnable} that will be executed
* when this future is complete. Must not be
* <code>null</code>.
* @param monitor an optional progress monitor to be passed to the
* progressRunnable when executed. May be
* <code>null</code>.
*/
public void addListener(IExecutor executor,
IProgressRunnable<ResultType> progressRunnable,
public void addListener(IExecutor executor, IProgressRunnable<ResultType> progressRunnable,
IProgressMonitor monitor);

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@
* Interface defining a block of code that can be run, return an Object result,
* and throw an arbitrary Exception.
*
* @param <ResultType>
* the type that will be returned by {@link #run(IProgressMonitor)}
* @param <ResultType> the type that will be returned by
* {@link #run(IProgressMonitor)}
* @since 1.1
*/
public interface IProgressRunnable<ResultType> {

/**
* Perform some action that returns a result or throws an exception
*
* @param monitor
* the IProgressMonitor associated with this callable
* @param monitor the IProgressMonitor associated with this callable
* @return result from the call
* @throws Exception
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* A runner that can execute {@link IProgressRunnable}s safely. Running an
* {@link IProgressRunnable} safely means not throwing any {@link Exception}
* possibly thrown by the given {@link IProgressRunnable}.
*
* @since 1.1
*
*/
Expand Down
Loading

0 comments on commit 1abded4

Please sign in to comment.