package com.google.common.util.concurrent;

import java.util.Collections;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public final class MoreExecutors
{
  // ERROR //
  static <T> T invokeAnyImpl(ListeningExecutorService paramListeningExecutorService, java.util.Collection<? extends Callable<T>> paramCollection, boolean paramBoolean, long paramLong)
    throws InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
  {
    // Byte code:
    //   0: aload_0
    //   1: invokestatic 20	com/google/common/base/Preconditions:checkNotNull	(Ljava/lang/Object;)Ljava/lang/Object;
    //   4: pop
    //   5: aload_1
    //   6: invokeinterface 26 1 0
    //   11: istore 6
    //   13: iload 6
    //   15: ifle +184 -> 199
    //   18: iconst_1
    //   19: istore 7
    //   21: iload 7
    //   23: invokestatic 30	com/google/common/base/Preconditions:checkArgument	(Z)V
    //   26: iload 6
    //   28: invokestatic 36	com/google/common/collect/Lists:newArrayListWithCapacity	(I)Ljava/util/ArrayList;
    //   31: astore 8
    //   33: invokestatic 42	com/google/common/collect/Queues:newLinkedBlockingQueue	()Ljava/util/concurrent/LinkedBlockingQueue;
    //   36: astore 9
    //   38: iload_2
    //   39: ifeq +166 -> 205
    //   42: invokestatic 48	java/lang/System:nanoTime	()J
    //   45: lstore 10
    //   47: aload_1
    //   48: invokeinterface 52 1 0
    //   53: astore 15
    //   55: aload 8
    //   57: aload_0
    //   58: aload 15
    //   60: invokeinterface 58 1 0
    //   65: checkcast 60	java/util/concurrent/Callable
    //   68: aload 9
    //   70: invokestatic 64	com/google/common/util/concurrent/MoreExecutors:submitAndAddQueueListener	(Lcom/google/common/util/concurrent/ListeningExecutorService;Ljava/util/concurrent/Callable;Ljava/util/concurrent/BlockingQueue;)Lcom/google/common/util/concurrent/ListenableFuture;
    //   73: invokeinterface 70 2 0
    //   78: pop
    //   79: iload 6
    //   81: iconst_1
    //   82: isub
    //   83: istore 17
    //   85: iconst_1
    //   86: istore 18
    //   88: aconst_null
    //   89: astore 19
    //   91: aload 9
    //   93: invokeinterface 75 1 0
    //   98: checkcast 77	java/util/concurrent/Future
    //   101: astore 21
    //   103: aload 21
    //   105: ifnonnull +38 -> 143
    //   108: iload 17
    //   110: ifle +101 -> 211
    //   113: iinc 17 255
    //   116: aload 8
    //   118: aload_0
    //   119: aload 15
    //   121: invokeinterface 58 1 0
    //   126: checkcast 60	java/util/concurrent/Callable
    //   129: aload 9
    //   131: invokestatic 64	com/google/common/util/concurrent/MoreExecutors:submitAndAddQueueListener	(Lcom/google/common/util/concurrent/ListeningExecutorService;Ljava/util/concurrent/Callable;Ljava/util/concurrent/BlockingQueue;)Lcom/google/common/util/concurrent/ListenableFuture;
    //   134: invokeinterface 70 2 0
    //   139: pop
    //   140: iinc 18 1
    //   143: aload 21
    //   145: ifnull +231 -> 376
    //   148: iinc 18 255
    //   151: aload 21
    //   153: invokeinterface 80 1 0
    //   158: astore 25
    //   160: aload 8
    //   162: invokeinterface 81 1 0
    //   167: astore 26
    //   169: aload 26
    //   171: invokeinterface 85 1 0
    //   176: ifeq +190 -> 366
    //   179: aload 26
    //   181: invokeinterface 58 1 0
    //   186: checkcast 77	java/util/concurrent/Future
    //   189: iconst_1
    //   190: invokeinterface 89 2 0
    //   195: pop
    //   196: goto -27 -> 169
    //   199: iconst_0
    //   200: istore 7
    //   202: goto -181 -> 21
    //   205: lconst_0
    //   206: lstore 10
    //   208: goto -161 -> 47
    //   211: iload 18
    //   213: ifne +62 -> 275
    //   216: aload 19
    //   218: ifnonnull +151 -> 369
    //   221: new 10	java/util/concurrent/ExecutionException
    //   224: dup
    //   225: aconst_null
    //   226: invokespecial 93	java/util/concurrent/ExecutionException:<init>	(Ljava/lang/Throwable;)V
    //   229: astore 31
    //   231: aload 31
    //   233: athrow
    //   234: astore 12
    //   236: aload 8
    //   238: invokeinterface 81 1 0
    //   243: astore 13
    //   245: aload 13
    //   247: invokeinterface 85 1 0
    //   252: ifeq +111 -> 363
    //   255: aload 13
    //   257: invokeinterface 58 1 0
    //   262: checkcast 77	java/util/concurrent/Future
    //   265: iconst_1
    //   266: invokeinterface 89 2 0
    //   271: pop
    //   272: goto -27 -> 245
    //   275: iload_2
    //   276: ifeq +56 -> 332
    //   279: getstatic 99	java/util/concurrent/TimeUnit:NANOSECONDS	Ljava/util/concurrent/TimeUnit;
    //   282: astore 28
    //   284: aload 9
    //   286: lload_3
    //   287: aload 28
    //   289: invokeinterface 102 4 0
    //   294: checkcast 77	java/util/concurrent/Future
    //   297: astore 21
    //   299: aload 21
    //   301: ifnonnull +11 -> 312
    //   304: new 12	java/util/concurrent/TimeoutException
    //   307: dup
    //   308: invokespecial 105	java/util/concurrent/TimeoutException:<init>	()V
    //   311: athrow
    //   312: invokestatic 48	java/lang/System:nanoTime	()J
    //   315: lstore 29
    //   317: lload_3
    //   318: lload 29
    //   320: lload 10
    //   322: lsub
    //   323: lsub
    //   324: lstore_3
    //   325: lload 29
    //   327: lstore 10
    //   329: goto -186 -> 143
    //   332: aload 9
    //   334: invokeinterface 108 1 0
    //   339: checkcast 77	java/util/concurrent/Future
    //   342: astore 21
    //   344: goto -201 -> 143
    //   347: astore 23
    //   349: new 10	java/util/concurrent/ExecutionException
    //   352: dup
    //   353: aload 23
    //   355: invokespecial 93	java/util/concurrent/ExecutionException:<init>	(Ljava/lang/Throwable;)V
    //   358: astore 22
    //   360: goto +37 -> 397
    //   363: aload 12
    //   365: athrow
    //   366: aload 25
    //   368: areturn
    //   369: aload 19
    //   371: astore 31
    //   373: goto -142 -> 231
    //   376: aload 19
    //   378: astore 22
    //   380: goto +17 -> 397
    //   383: astore 12
    //   385: aload 19
    //   387: pop
    //   388: goto -152 -> 236
    //   391: astore 24
    //   393: aload 24
    //   395: astore 22
    //   397: aload 22
    //   399: astore 19
    //   401: goto -310 -> 91
    //
    // Exception table:
    //   from	to	target	type
    //   42	47	234	finally
    //   47	79	234	finally
    //   231	234	234	finally
    //   151	160	347	java/lang/RuntimeException
    //   91	103	383	finally
    //   116	140	383	finally
    //   151	160	383	finally
    //   221	231	383	finally
    //   279	299	383	finally
    //   304	312	383	finally
    //   312	317	383	finally
    //   332	344	383	finally
    //   349	360	383	finally
    //   151	160	391	java/util/concurrent/ExecutionException
  }

  public static ListeningExecutorService sameThreadExecutor()
  {
    return new SameThreadExecutorService(null);
  }

  private static <T> ListenableFuture<T> submitAndAddQueueListener(ListeningExecutorService paramListeningExecutorService, Callable<T> paramCallable, BlockingQueue<Future<T>> paramBlockingQueue)
  {
    final ListenableFuture localListenableFuture = paramListeningExecutorService.submit(paramCallable);
    localListenableFuture.addListener(new Runnable()
    {
      public void run()
      {
        this.val$queue.add(localListenableFuture);
      }
    }
    , sameThreadExecutor());
    return localListenableFuture;
  }

  private static class SameThreadExecutorService extends AbstractListeningExecutorService
  {
    private final Lock lock = new ReentrantLock();
    private int runningTasks = 0;
    private boolean shutdown = false;
    private final Condition termination = this.lock.newCondition();

    private void endTask()
    {
      this.lock.lock();
      try
      {
        this.runningTasks = (-1 + this.runningTasks);
        if (isTerminated())
          this.termination.signalAll();
        return;
      }
      finally
      {
        this.lock.unlock();
      }
    }

    private void startTask()
    {
      this.lock.lock();
      try
      {
        if (isShutdown())
          throw new RejectedExecutionException("Executor already shutdown");
      }
      finally
      {
        this.lock.unlock();
      }
      this.runningTasks = (1 + this.runningTasks);
      this.lock.unlock();
    }

    public boolean awaitTermination(long paramLong, TimeUnit paramTimeUnit)
      throws InterruptedException
    {
      long l1 = paramTimeUnit.toNanos(paramLong);
      this.lock.lock();
      try
      {
        while (true)
        {
          boolean bool = isTerminated();
          if (bool)
            return true;
          if (l1 <= 0L)
            return false;
          long l2 = this.termination.awaitNanos(l1);
          l1 = l2;
        }
      }
      finally
      {
        this.lock.unlock();
      }
    }

    public void execute(Runnable paramRunnable)
    {
      startTask();
      try
      {
        paramRunnable.run();
        return;
      }
      finally
      {
        endTask();
      }
    }

    public boolean isShutdown()
    {
      this.lock.lock();
      try
      {
        boolean bool = this.shutdown;
        return bool;
      }
      finally
      {
        this.lock.unlock();
      }
    }

    public boolean isTerminated()
    {
      this.lock.lock();
      try
      {
        if (this.shutdown)
        {
          int i = this.runningTasks;
          if (i == 0)
          {
            bool = true;
            return bool;
          }
        }
        boolean bool = false;
      }
      finally
      {
        this.lock.unlock();
      }
    }

    public void shutdown()
    {
      this.lock.lock();
      try
      {
        this.shutdown = true;
        return;
      }
      finally
      {
        this.lock.unlock();
      }
    }

    public List<Runnable> shutdownNow()
    {
      shutdown();
      return Collections.emptyList();
    }
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.google.common.util.concurrent.MoreExecutors
 * JD-Core Version:    0.6.2
 */