class ProgressEventHandler implements Consumer<ProgressEvent> {

  @Override
  public void accept(ProgressEvent progressEvent) {
    Allocation allocation = progressEvent.getAllocation();
    long progressUnits = progressEvent.getUnits();
    double allocationFraction = allocation.getFractionOfRoot();

    if (progressUnits != 0) {
      progress.add(progressUnits * allocationFraction);
    }

    if (completionTracker.updateProgress(allocation, progressUnits)) {
      // Note: Could produce false positives.
      updateNotifier.accept(new Update(progress.sum(), completionTracker.getUnfinishedLeafTasks()));
    }
  }

  public  ProgressEventHandler(Consumer<Update> updateNotifier);

}