Package aQute.libg.forker
Class Forker<T>
java.lang.Object
aQute.libg.forker.Forker<T>
- Type Parameters:
T
-
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.-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel
(long ms) Cancel the forker.private void
check()
(package private) void
Called when the target has ran by the Job.void
doWhen
(Collection<? extends T> dependencies, T target, Runnable runnable) Schedule a job for execution when the dependencies are done of target are done.int
getCount()
private void
schedule()
void
start
(long ms) void
sync
(long ms)
-
Field Details
-
executor
-
waiting
-
executing
-
canceled
-
count
private int count
-
-
Constructor Details
-
Forker
Constructor- Parameters:
executor
-
-
Forker
public Forker()Constructor
-
-
Method Details
-
doWhen
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
- Throws:
InterruptedException
-
check
private void check() -
sync
- Throws:
InterruptedException
-
schedule
private void schedule() -
done
Called when the target has ran by the Job.- Parameters:
done
-
-
cancel
Cancel the forker.- Throws:
InterruptedException
-
getCount
public int getCount()
-