Class Forker<T>

java.lang.Object
aQute.libg.forker.Forker<T>
Type Parameters:
T -

public class Forker<T> extends Object
A Forker is good in parallel scheduling tasks with dependencies. You can add tasks with doWhen(Collection, Object, Runnable). The collection is the list of dependencies, the object is the target, and the runnable is run to update the target. The runnable will only run when all its dependencies have ran their associated runnable.
  • Field Details

  • Constructor Details

    • Forker

      public Forker(Executor executor)
      Constructor
      Parameters:
      executor -
    • Forker

      public Forker()
      Constructor
  • Method Details

    • doWhen

      public void doWhen(Collection<? extends T> dependencies, T target, Runnable runnable)
      Schedule a job for execution when the dependencies are done of target are done.
      Parameters:
      dependencies - the dependencies that must have run
      target - the target, is removed from all the dependencies when it ran
      runnable - the runnable to run
    • start

      public void start(long ms) throws InterruptedException
      Throws:
      InterruptedException
    • check

      private void check()
    • sync

      public void sync(long ms) throws InterruptedException
      Throws:
      InterruptedException
    • schedule

      private void schedule()
    • done

      void done(Forker<T>.Job done)
      Called when the target has ran by the Job.
      Parameters:
      done -
    • cancel

      public void cancel(long ms) throws InterruptedException
      Cancel the forker.
      Throws:
      InterruptedException
    • getCount

      public int getCount()