org.eclipse.equinox.concurrent_1.0.200.v20110502

16:43:48.733 INFO  jd.cli.Main - Decompiling org.eclipse.equinox.concurrent_1.0.200.v20110502.jar
package org.eclipse.equinox.concurrent.future;

import org.eclipse.core.runtime.IProgressMonitor;

class AbstractExecutor$1
  implements IProgressRunnable
{
  final AbstractExecutor this$0;
  private final Runnable val$runnable;
  
  AbstractExecutor$1(AbstractExecutor paramAbstractExecutor, Runnable paramRunnable)
  {
    this$0 = paramAbstractExecutor;val$runnable = paramRunnable;
  }
  
  public Object run(IProgressMonitor monitor)
    throws Exception
  {
    val$runnable.run();
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.concurrent.future.AbstractExecutor.1
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.concurrent.future;

import org.eclipse.core.runtime.IProgressMonitor;

public abstract class AbstractExecutor
  implements IRunnableExecutor, IExecutor
{
  public void execute(Runnable runnable)
  {
    execute(new IProgressRunnable()
    {
      private final Runnable val$runnable;
      
      public Object run(IProgressMonitor monitor)
        throws Exception
      {
        val$runnable.run();
        return null;
      }
    }, null);
  }
  
  public abstract IFuture execute(IProgressRunnable paramIProgressRunnable, IProgressMonitor paramIProgressMonitor);
  
  protected abstract AbstractFuture createFuture(IProgressMonitor paramIProgressMonitor);
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.concurrent.future.AbstractExecutor
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.concurrent.future;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;

public abstract class AbstractFuture
  implements IFuture, ISafeProgressRunner
{
  public abstract boolean isCanceled();
  
  public abstract IProgressMonitor getProgressMonitor();
  
  public abstract void runWithProgress(IProgressRunnable paramIProgressRunnable);
  
  public abstract boolean isDone();
  
  public abstract boolean hasValue();
  
  public abstract IStatus getStatus();
  
  public abstract Object get(long paramLong)
    throws InterruptedException, TimeoutException, OperationCanceledException;
  
  public abstract Object get()
    throws InterruptedException, OperationCanceledException;
  
  public abstract boolean cancel();
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.concurrent.future.AbstractFuture
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.concurrent.future;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ProgressMonitorWrapper;

public class FutureProgressMonitor
  extends ProgressMonitorWrapper
{
  private IProgressMonitor monitor;
  private Object lock = new Object();
  
  public FutureProgressMonitor(IProgressMonitor progressMonitor)
  {
    super(progressMonitor);
  }
  
  public void beginTask(String name, int totalWork)
  {
    super.beginTask(name, totalWork);
    synchronized (lock)
    {
      if (monitor != null) {
        monitor.beginTask(name, totalWork);
      }
    }
  }
  
  public void done()
  {
    super.done();
    synchronized (lock)
    {
      monitor.done();
      monitor = null;
    }
  }
  
  public void internalWorked(double work)
  {
    super.internalWorked(work);
    synchronized (lock)
    {
      if (monitor != null) {
        monitor.internalWorked(work);
      }
    }
  }
  
  public void setCanceled(boolean value)
  {
    super.setCanceled(value);
    synchronized (lock)
    {
      if (monitor != null) {
        monitor.setCanceled(value);
      }
    }
  }
  
  public void setTaskName(String name)
  {
    super.setTaskName(name);
    synchronized (lock)
    {
      if (monitor != null) {
        monitor.setTaskName(name);
      }
    }
  }
  
  public void subTask(String name)
  {
    super.subTask(name);
    synchronized (lock)
    {
      if (monitor != null) {
        monitor.subTask(name);
      }
    }
  }
  
  public void worked(int work)
  {
    super.worked(work);
    synchronized (lock)
    {
      if (monitor != null) {
        monitor.worked(work);
      }
    }
  }
  
  public void setChildProgressMonitor(IProgressMonitor value)
  {
    synchronized (lock)
    {
      monitor = value;
      if ((monitor != null) && (isCanceled())) {
        monitor.setCanceled(true);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.concurrent.future.FutureProgressMonitor
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.concurrent.future;

import org.eclipse.core.runtime.IProgressMonitor;

public abstract interface IExecutor
{
  public abstract IFuture execute(IProgressRunnable paramIProgressRunnable, IProgressMonitor paramIProgressMonitor);
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.concurrent.future.IExecutor
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.concurrent.future;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;

public abstract interface IFuture
{
  public abstract boolean cancel();
  
  public abstract Object get()
    throws InterruptedException, OperationCanceledException;
  
  public abstract Object get(long paramLong)
    throws InterruptedException, TimeoutException, OperationCanceledException;
  
  public abstract IStatus getStatus();
  
  public abstract boolean hasValue();
  
  public abstract boolean isDone();
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.concurrent.future.IFuture
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.concurrent.future;

import org.eclipse.core.runtime.IProgressMonitor;

public abstract interface IProgressRunnable
{
  public abstract Object run(IProgressMonitor paramIProgressMonitor)
    throws Exception;
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.concurrent.future.IProgressRunnable
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.concurrent.future;

public abstract interface IRunnableExecutor
{
  public abstract void execute(Runnable paramRunnable);
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.concurrent.future.IRunnableExecutor
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.concurrent.future;

public abstract interface ISafeProgressRunner
{
  public abstract void runWithProgress(IProgressRunnable paramIProgressRunnable);
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.concurrent.future.ISafeProgressRunner
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.concurrent.future;

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;

public class ImmediateExecutor
  extends AbstractExecutor
  implements IExecutor, IRunnableExecutor
{
  protected AbstractFuture createFuture(IProgressMonitor monitor)
  {
    return new SingleOperationFuture(monitor);
  }
  
  public IFuture execute(IProgressRunnable runnable, IProgressMonitor monitor)
  {
    Assert.isNotNull(runnable);
    AbstractFuture sof = createFuture(monitor);
    
    sof.runWithProgress(runnable);
    return sof;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.concurrent.future.ImmediateExecutor
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.concurrent.future;

import org.eclipse.core.runtime.ISafeRunnable;

class SingleOperationFuture$1
  implements ISafeRunnable
{
  final SingleOperationFuture this$0;
  private final IProgressRunnable val$runnable;
  
  SingleOperationFuture$1(SingleOperationFuture paramSingleOperationFuture, IProgressRunnable paramIProgressRunnable)
  {
    this$0 = paramSingleOperationFuture;val$runnable = paramIProgressRunnable;
  }
  
  public void handleException(Throwable exception)
  {
    if (!this$0.isCanceled()) {
      this$0.setException(exception);
    }
  }
  
  public void run()
    throws Exception
  {
    Object result = val$runnable.run(this$0.getProgressMonitor());
    if (!this$0.isCanceled()) {
      this$0.set(result);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.concurrent.future.SingleOperationFuture.1
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.concurrent.future;

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;

public class SingleOperationFuture
  extends AbstractFuture
{
  private static final String PLUGIN_ID = "org.eclipse.equinox.concurrent";
  private Object resultValue = null;
  private IStatus status = null;
  private TimeoutException timeoutException = null;
  protected IProgressMonitor progressMonitor;
  
  public SingleOperationFuture()
  {
    this(null);
  }
  
  public SingleOperationFuture(IProgressMonitor progressMonitor)
  {
    this.progressMonitor = new FutureProgressMonitor(progressMonitor == null ? new NullProgressMonitor() : progressMonitor);
  }
  
  public synchronized Object get()
    throws InterruptedException, OperationCanceledException
  {
    throwIfCanceled();
    while (!isDone()) {
      wait();
    }
    throwIfCanceled();
    return resultValue;
  }
  
  public synchronized Object get(long waitTimeInMillis)
    throws InterruptedException, TimeoutException, OperationCanceledException
  {
    if (waitTimeInMillis < 0L) {
      throw new IllegalArgumentException("waitTimeInMillis must be => 0");
    }
    throwIfCanceled();
    if (timeoutException != null) {
      throw timeoutException;
    }
    if (isDone()) {
      return resultValue;
    }
    long startTime = System.currentTimeMillis();
    long waitTime = waitTimeInMillis;
    do
    {
      wait(waitTime);
      throwIfCanceled();
      if (isDone()) {
        return resultValue;
      }
      waitTime = waitTimeInMillis - (System.currentTimeMillis() - startTime);
    } while (waitTime > 0L);
    throw createTimeoutException(waitTimeInMillis);
  }
  
  public synchronized boolean isDone()
  {
    return status != null;
  }
  
  public void runWithProgress(IProgressRunnable runnable)
  {
    Assert.isNotNull(runnable);
    if (!isCanceled()) {
      SafeRunner.run(new ISafeRunnable()
      {
        private final IProgressRunnable val$runnable;
        
        public void handleException(Throwable exception)
        {
          if (!isCanceled()) {
            setException(exception);
          }
        }
        
        public void run()
          throws Exception
        {
          Object result = val$runnable.run(getProgressMonitor());
          if (!isCanceled()) {
            set(result);
          }
        }
      });
    }
  }
  
  public synchronized IStatus getStatus()
  {
    return status;
  }
  
  public boolean hasValue()
  {
    return isDone();
  }
  
  public synchronized boolean cancel()
  {
    if (isDone()) {
      return false;
    }
    if (isCanceled()) {
      return false;
    }
    setStatus(new Status(8, "org.eclipse.equinox.concurrent", 8, "Operation canceled", null));
    getProgressMonitor().setCanceled(true);
    notifyAll();
    return true;
  }
  
  protected synchronized void setException(Throwable ex)
  {
    setStatus(new Status(4, "org.eclipse.equinox.concurrent", 4, "Exception during operation", ex));
    notifyAll();
  }
  
  protected synchronized void set(Object newValue)
  {
    resultValue = newValue;
    setStatus(Status.OK_STATUS);
    notifyAll();
  }
  
  private synchronized void setStatus(IStatus status)
  {
    this.status = status;
  }
  
  private TimeoutException createTimeoutException(long timeout)
  {
    setStatus(new Status(4, "org.eclipse.equinox.concurrent", 4, "Operation timeout after " + timeout + "ms", null));
    timeoutException = new TimeoutException("Single operation timeout", timeout);
    return timeoutException;
  }
  
  private void throwIfCanceled()
    throws OperationCanceledException
  {
    IProgressMonitor pm = getProgressMonitor();
    if ((pm != null) && (pm.isCanceled())) {
      throw new OperationCanceledException("Single operation canceled");
    }
  }
  
  public synchronized IProgressMonitor getProgressMonitor()
  {
    return progressMonitor;
  }
  
  public synchronized boolean isCanceled()
  {
    return getProgressMonitor().isCanceled();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.concurrent.future.SingleOperationFuture
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.concurrent.future;

class ThreadsExecutor$1
  implements Runnable
{
  final ThreadsExecutor this$0;
  private final ISafeProgressRunner val$runner;
  private final IProgressRunnable val$progressRunnable;
  
  ThreadsExecutor$1(ThreadsExecutor paramThreadsExecutor, ISafeProgressRunner paramISafeProgressRunner, IProgressRunnable paramIProgressRunnable)
  {
    this$0 = paramThreadsExecutor;val$runner = paramISafeProgressRunner;val$progressRunnable = paramIProgressRunnable;
  }
  
  public void run()
  {
    val$runner.runWithProgress(val$progressRunnable);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.concurrent.future.ThreadsExecutor.1
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.concurrent.future;

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;

public class ThreadsExecutor
  extends AbstractExecutor
{
  protected String createThreadName(IProgressRunnable runnable)
  {
    return "ThreadsExecutor(" + runnable.toString() + ")";
  }
  
  protected Runnable createRunnable(ISafeProgressRunner runner, IProgressRunnable progressRunnable)
  {
    new Runnable()
    {
      private final ISafeProgressRunner val$runner;
      private final IProgressRunnable val$progressRunnable;
      
      public void run()
      {
        val$runner.runWithProgress(val$progressRunnable);
      }
    };
  }
  
  protected void configureThreadForExecution(Thread thread)
  {
    thread.setDaemon(true);
  }
  
  protected AbstractFuture createFuture(IProgressMonitor monitor)
  {
    return new SingleOperationFuture(monitor);
  }
  
  public synchronized IFuture execute(IProgressRunnable runnable, IProgressMonitor monitor)
    throws IllegalThreadStateException
  {
    Assert.isNotNull(runnable);
    
    AbstractFuture sof = createFuture(monitor);
    
    Thread thread = new Thread(createRunnable(sof, runnable), createThreadName(runnable));
    configureThreadForExecution(thread);
    
    thread.start();
    return sof;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.concurrent.future.ThreadsExecutor
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.concurrent.future;

public class TimeoutException
  extends Exception
{
  private static final long serialVersionUID = -3198307514925924297L;
  private final long duration;
  
  public TimeoutException(long time)
  {
    duration = time;
  }
  
  public TimeoutException(String message, long time)
  {
    super(message);
    duration = time;
  }
  
  public long getDuration()
  {
    return duration;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.concurrent.future.TimeoutException
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
1

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd