groovyx.gpars.dataflow.operator
Class CountingPoisonPill

java.lang.Object
  extended by groovyx.gpars.dataflow.operator.PoisonPill
      extended by 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

Field Summary
private  PoisonTrackCounter poisonTrackCounter
           
 
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 groovyx.gpars.dataflow.operator.PoisonPill
getImmediateInstance, getInstance, isImmediate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

poisonTrackCounter

private final PoisonTrackCounter poisonTrackCounter
Constructor Detail

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.
Method Detail

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 wait
unit - 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

Copyright © 2008–2012 Václav Pech. All Rights Reserved.