Return the first result of these tasks<br>
IGNORE EXCEPTIONS.

@param tasks
@return can be null
@throws IllegalStateException If all tasks failed.
167070
@SafeVarargs
  public static <T> T firstSuccess(FuncE0<T, ?>... tasks) throws IllegalStateException {
    for (FuncE0<T, ?> task : tasks) {
      Either<T, ?> res = throwToReturn(task);
      if (res.isLeft()) {
        return res.getLeft();
      }
    }
    throw new IllegalStateException("All tasks failed");
  }
686009
public synchronized Collection<TaskTrackerStatus> taskTrackers() {
    Collection<TaskTrackerStatus> ttStatuses;
    synchronized (taskTrackers) {
      ttStatuses =
        new ArrayList<TaskTrackerStatus>(taskTrackers.values().size());
      for (TaskTracker tt : taskTrackers.values()) {
        ttStatuses.add(tt.getStatus());
      }
    }
    return ttStatuses;
  }
718070
public static <T> T getFirst(Collection<T> collection) {
		if (isEmpty(collection)) {
			return null;
		}
		if (collection instanceof List) {
			return ((List<T>) collection).get(0);
		}
		return collection.iterator().next();
	}
1269292
public static <T> T first(Iterable<T> objects) {
        if (objects != null) {
            for (T object : objects) {
                return object;
            }
        }
        return null;
    }
760954
public java.util.List<String> getTasks() {
        if (tasks == null) {
            tasks = new com.amazonaws.internal.SdkInternalList<String>();
        }
        return tasks;
    }
89449
public static void waitFinished(Collection<? extends Task<?,?>> tasks) throws Exception {
		for (Task<?,?> t : tasks) {
			t.getOutput().blockThrow(0);
		}
	}
369264
@Nullable
  public ResultT first() {
    final CoreRemoteMongoCursor<ResultT> cursor = iterator();
    if (!cursor.hasNext()) {
      return null;
    }
    return cursor.next();
  }
1156006
public java.util.List<String> getTaskSets() {
        if (taskSets == null) {
            taskSets = new com.amazonaws.internal.SdkInternalList<String>();
        }
        return taskSets;
    }
1083819
public static <T> T firstNotNull(final T... objects) {
        for (final T object : objects) {
            if (object != null) {
                return object;
            }
        }
        return null;
    }
1031537
@Service
    public List<Task> getListOfPendingTask(String taskType, Integer start, Integer count) {
        List<Task> tasks = executionService.getPendingTasksForTaskType(taskType);
        int total = start + count;
        total = (tasks.size() > total) ? total : tasks.size();
        if (start > tasks.size()) start = tasks.size();
        return tasks.subList(start, total);
    }
404981
public List<TaskLock> findLocksForTask(final Task task)
  {
    giant.lock();

    try {
      return Lists.transform(
          findLockPossesForTask(task), new Function<TaskLockPosse, TaskLock>()
          {
            @Override
            public TaskLock apply(TaskLockPosse taskLockPosse)
            {
              return taskLockPosse.getTaskLock();
            }
          }
      );
    }
    finally {
      giant.unlock();
    }
  }
939611
public static String getTaskFailureExceptions(List<TaskState> taskStates) {
    StringBuffer sb = new StringBuffer();

    // Add task failure messages in a group followed by task failure exceptions
    appendTaskStateValues(taskStates, sb, TASK_FAILURE_MESSAGE_KEY);
    appendTaskStateValues(taskStates, sb, ConfigurationKeys.TASK_FAILURE_EXCEPTION_KEY);

    return sb.toString();
  }
496967
public CompositeOperation<TaskExecution> getTasks() {
        List<TaskExecution> taskExecutions = CollectionUtils.sort(tasks.values(), slowestFirst());
        return new CompositeOperation<TaskExecution>(taskExecutions);
    }
338968
public static <T> IQueryResult<T> packageResult(List<T> results) {
        return packageResult(results, null);
    }
731400
@SafeVarargs
	public static <T> Iterator<Promise<T>> asPromises(@NotNull AsyncSupplier<? extends T>... tasks) {
		return asPromises(asList(tasks));
	}
669273
public List<T> results() throws InterruptedException {
        while (true) {
            synchronized (this) {
                if (completed) {
                    return results == null ? Collections.emptyList()
                        : Collections.unmodifiableList(results);
                }
                wait();
            }
        }
    }
190170
public Result[] executeAndWait(Command[] commands) {
        Result[] results = new Result[commands.length];
        if (numProcessors == 1) {
            // optimize for one processor
            for (int i = 0; i < commands.length; i++) {
                Object obj = null;
                InvocationTargetException ex = null;
                try {
                    obj = commands[i].call();
                } catch (Exception e) {
                    ex = new InvocationTargetException(e);
                }
                results[i] = new Result(obj, ex);
            }
        } else {
            FutureResult[] futures = new FutureResult[commands.length];
            for (int i = 0; i < commands.length; i++) {
                final Command c = commands[i];
                futures[i] = new FutureResult();
                Runnable r = futures[i].setter(new Callable() {
                    public Object call() throws Exception {
                        return c.call();
                    }
                });
                try {
                    executor.execute(r);
                } catch (InterruptedException e) {
                    // run with current thread instead
                    r.run();
                }
            }
            // wait for all results
            boolean interrupted = false;
            for (int i = 0; i < futures.length; i++) {
                Object obj = null;
                InvocationTargetException ex = null;
                for (;;) {
                    try {
                        obj = futures[i].get();
                    } catch (InterruptedException e) {
                        interrupted = true;
                        // reset interrupted status and try again
                        Thread.interrupted();
                        continue;
                    } catch (InvocationTargetException e) {
                        ex = e;
                    }
                    results[i] = new Result(obj, ex);
                    break;
                }
            }
            if (interrupted) {
                // restore interrupt status again
                Thread.currentThread().interrupt();
            }
        }
        return results;
    }