Wraps an iterator so that when iterated, a progress bar is shown to track the traversal progress.
@param it Underlying iterator
@param task Task name
421366
public static <T> Iterator<T> wrap(Iterator<T> it, String task) {
        return new ProgressBarWrappedIterator<>(it, task, -1); // indefinite progress bar
    }
1020009
private void queueOrOfferMPTask(TransactionTask task)
    {
        // The pending map will only have an entry for the transaction if the first fragment is
        // still pending durability.
        Queue<TransactionTask> pendingTasks = m_mpsPendingDurability.get(task.getTxnId());
        if (pendingTasks != null) {
            pendingTasks.offer(task);
        } else {
            m_pendingTasks.offer(task);
        }
    }
862375
def progress_task(name=None, t=INFO, max_value=100, *args, **kwargs):
    
    return task(name=name, t=t, init_progress=True, max_value=max_value,
                *args, **kwargs)
895014
@SuppressWarnings("checkstyle:illegalcatch")
  private byte[] runTask() throws TaskCallFailure {
    try {
      final byte[] result;
      if (this.memento.isPresent()) {
        LOG.log(Level.FINEST, "Calling Task.call() with a memento");
        result = this.task.call(this.memento.get());
      } else {
        LOG.log(Level.FINEST, "Calling Task.call() without a memento");
        result = this.task.call(null);
      }
      LOG.log(Level.FINEST, "Task.call() exited cleanly.");
      return result;
    } catch (final Throwable throwable) {
      throw new TaskCallFailure(throwable);
    }
  }
1098911
@Override
    public void requeue(Task task) {
        this.inprocess.remove(task);
        task.incrementAttempts();
        this.queue.add(task);
    }
99489
public void processTasks(List<Row> bars, List<Row> expandedTasks, List<Row> tasks, List<Row> milestones)
   {
      List<Row> parentBars = buildRowHierarchy(bars, expandedTasks, tasks, milestones);
      createTasks(m_project, "", parentBars);
      deriveProjectCalendar();
      updateStructure();
   }
363133
private void bindProgressBar(final ServiceTaskBase<?> task, final ProgressBar progressBar) {

        // Perform this binding into the JAT to respect widget and task API
        JRebirth.runIntoJAT("Bind ProgressBar to " + task.getServiceHandlerName(),
                            () -> {
                                // Avoid the progress bar to display 100% at start up
                                task.updateProgress(0, 0);
                                // Bind the progress bar
                                progressBar.progressProperty().bind(task.workDoneProperty().divide(task.totalWorkProperty()));
                            });

    }
66242
public static <T, S extends BaseStream<T, S>> Stream<T> wrap(S stream, String task) {
        ProgressBarBuilder pbb = new ProgressBarBuilder().setTaskName(task);
        return wrap(stream, pbb);
    }
807440
@GuardedBy("evictionLock")
    void runTasksInChain(Task task) {
        while (task != null) {
            Task current = task;
            task = task.getNext();
            current.setNext(null);
            current.run();
        }
    }
719543
async def start_task(self, task: Task) -> None:
        ''''''

        try:
            Log.debug('task %s starting', task.name)
            before = time.time()
            task.counters['last_run'] = before

            task.running = True
            self.running_tasks.add(task)
            await task.run_task()
            Log.debug('task %s completed', task.name)

        except CancelledError:
            Log.debug('task %s cancelled', task.name)

        except Exception:
            Log.exception('unhandled exception in task %s', task.name)

        finally:
            self.running_tasks.discard(task)
            task.running = False
            task.task = None

            after = time.time()
            total = after - before
            task.counters['last_completed'] = after
            task.counters['duration'] = total
1012967
private void bindProgressProperty(final ServiceTaskBase<?> task, final DoubleProperty progressProperty) {

        // Perform this binding into the JAT to respect widget and task API
        JRebirth.runIntoJAT("Bind Progress Property to " + task.getServiceHandlerName(),
                            () -> {
                                // Avoid the progress bar to display 100% at start up
                                task.updateProgress(0, 0);
                                // Bind the progress bar
                                progressProperty.bind(task.workDoneProperty().divide(task.totalWorkProperty()));
                            });

    }
568984
private <T> Collection<? extends Callable<T>> wrap(Collection<? extends Callable<T>> tasks) {
        List<Callable<T>> wrappedTasks = new ArrayList<Callable<T>>();
        Iterator<? extends Callable<T>> i = tasks.iterator();
        while (i.hasNext()) {
            Callable<T> c = wrap(i.next());
            if (serverStopping)
                wrappedTasks.add(c);
            else
                wrappedTasks.add(new CallableWrapper<T>(c));
        }
        return wrappedTasks;
    }
865573
public static void call(Runnable task) {
        try {
            call(() -> {
                task.run();
                return true;
            });
        } catch (Exception e) {
            // It's safe to throw unsafely here because the Callable we passed never throws a checked exception.
            Exceptions.throwUnsafely(e);
        }
    }
8797
public void runTask(Handler<Task> task) {
    if (currentTask == null) {
      currentTask = new Task(this);
      task.handle(currentTask);
    } else {
      queue.add(task);
    }
  }
145336
public void submit(Task<? extends TaskResult> task) {

        // Increment the counter which indicates the number of results to
        // expect. This must be done BEFORE actually submitting the task for
        // execution.
        remainingTasks.incrementAndGet();

        // Increment the statistics and put the task on the correct queue.
        stats.incrementStartedTasks(task.resultType);
        executors.get(task.resultType).submit(task);

        // Make sure that the task gets added to the results queue.
        resultsQueue.add(task);
        stats.updateMemoryInfo();
    }
852480
private void writeTask(Task task) throws IOException
   {
      writeFields(null, task, TaskField.values());
      for (Task child : task.getChildTasks())
      {
         writeTask(child);
      }
   }
574608
private T nextWrapper(Iterator<T> it) {
        try {
            if (trace != null) {
                trace.add(new TraceEntry(System.nanoTime(), System.currentTimeMillis(),
                        NextOrHasNext.NEXT, debugLabels.get(it)));
            }
            return it.next();
        } catch (RuntimeException e) {
            logTrace();
            throw e;
        }
    }