Package aQute.libg.forker
Class Forker<T>
- java.lang.Object
-
- aQute.libg.forker.Forker<T>
-
- Type Parameters:
T
-
public class Forker<T> extends java.lang.Object
A Forker is good in parallel scheduling tasks with dependencies. You can add tasks withdoWhen(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.- Author:
- aqute
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel(long ms)
Cancel the forker.void
doWhen(java.util.Collection<? extends T> dependencies, T target, java.lang.Runnable runnable)
Schedule a job for execution when the dependencies are done of target are done.int
getCount()
void
start(long ms)
void
sync(long ms)
-
-
-
Method Detail
-
doWhen
public void doWhen(java.util.Collection<? extends T> dependencies, T target, java.lang.Runnable runnable)
Schedule a job for execution when the dependencies are done of target are done.- Parameters:
dependencies
- the dependencies that must have runtarget
- the target, is removed from all the dependencies when it ranrunnable
- the runnable to run
-
start
public void start(long ms) throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
sync
public void sync(long ms) throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
cancel
public void cancel(long ms) throws java.lang.InterruptedException
Cancel the forker.- Throws:
java.lang.InterruptedException
-
getCount
public int getCount()
-
-