org.codehaus.gpars

groovyx.gpars.dataflow.operator
[Java] Class CountingPoisonPill

java.lang.Object
  groovyx.gpars.dataflow.operator.PoisonPill
      groovyx.gpars.dataflow.operator.CountingPoisonPill

public final class CountingPoisonPill
extends PoisonPill

Represents a PoisonPill that counts stopped operators and can be used to wait for all the operators to terminate.

Authors:
Vaclav Pech


Field Summary
private java.util.concurrent.atomic.AtomicInteger counter

private DataflowVariable termination

 
Fields inherited from class PoisonPill
ourInstance
 
Constructor Summary
CountingPoisonPill(int count)

Creates an instance that could be used to stop operators in a network.

 
Method Summary
void countDown()

Promise getTermination()

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 PoisonPill
countDown, getInstance
 

Field Detail

counter

private final java.util.concurrent.atomic.AtomicInteger counter


termination

private final DataflowVariable termination


 
Constructor Detail

CountingPoisonPill

public CountingPoisonPill(int count)
Creates an 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

countDown

@Override
void countDown()


getTermination

public Promise getTermination()


join

public void join()
Blocks until the number of terminated operators reaches the number specified in the constructor
throws:
InterruptedException If the current thread gets interrupted during the blocking


join

public void join(long timeout, java.util.concurrent.TimeUnit unit)
Blocks until the number of terminated operators reaches the number specified in the constructor
throws:
InterruptedException If the current thread gets interrupted during the blocking
Parameters:
timeout - the maximum time to wait
unit - the time unit of the timeout argument


 

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