groovyx.gpars.dataflow.operator
Class CountingPoisonPill
java.lang.Object
groovyx.gpars.dataflow.operator.PoisonPill
groovyx.gpars.dataflow.operator.CountingPoisonPill
- All Implemented Interfaces:
- ControlMessage
public final class CountingPoisonPill
- extends PoisonPill
Represents a non-immediate PoisonPill that counts stopped operators and can be used to wait for all the operators to terminate.
- Author:
- Vaclav Pech
Constructor Summary |
CountingPoisonPill(int count)
Creates a non-immediate instance that could be used to stop operators in a network. |
Method Summary |
(package private) void |
countDown()
|
Promise<java.lang.Boolean> |
getTermination()
Retrieves the promise for termination |
void |
join()
Blocks until the number of terminated operators reaches the number specified in the constructor |
void |
join(long timeout,
java.util.concurrent.TimeUnit unit)
Blocks until the number of terminated operators reaches the number specified in the constructor |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
poisonTrackCounter
private final PoisonTrackCounter poisonTrackCounter
CountingPoisonPill
public CountingPoisonPill(int count)
- Creates a non-immediate instance that could be used to stop operators in a network.
- Parameters:
count
- The number of operators that need to be stopped before the join() method returns.
join
public void join()
throws java.lang.InterruptedException
- Blocks until the number of terminated operators reaches the number specified in the constructor
- Throws:
java.lang.InterruptedException
- If the current thread gets interrupted during the blocking
join
public void join(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
- Blocks until the number of terminated operators reaches the number specified in the constructor
- Parameters:
timeout
- the maximum time to waitunit
- the time unit of the timeout
argument
- Throws:
java.lang.InterruptedException
- If the current thread gets interrupted during the blocking
getTermination
public Promise<java.lang.Boolean> getTermination()
- Retrieves the promise for termination
- Returns:
- A Promise instance that will be bound when all the requested dataflow pocessors have been terminated
countDown
void countDown()
- Overrides:
countDown
in class PoisonPill