jbarrier

edu.bonn.cs.net.jbarrier.barrier
Class CentralBarrier

java.lang.Object
  extended by edu.bonn.cs.net.jbarrier.barrier.AbstractBarrier
      extended by edu.bonn.cs.net.jbarrier.barrier.CentralBarrier
All Implemented Interfaces:
Barrier
Direct Known Subclasses:
DoubleCentralReduction, FloatCentralReduction, IntCentralReduction, LongCentralReduction

public class CentralBarrier
extends AbstractBarrier

Implementation of a central barrier algorithm based on a shared counter. Of all algorithms in this package, this one is most similar to the CyclicBarrier.

Version:
1.0
Author:
Patrick Peschlow, Ivan Castilla Rodriguez

Field Summary
protected  java.util.concurrent.atomic.AtomicInteger counter_
          The central counter variable.
protected  boolean go_
          Global out flag.
 
Fields inherited from class edu.bonn.cs.net.jbarrier.barrier.AbstractBarrier
action_, genericReductor_, numParties_
 
Constructor Summary
CentralBarrier(int numParties)
          Constructor (if no action is used).
CentralBarrier(int numParties, java.lang.Runnable barrierAction)
          Constructor.
CentralBarrier(int numParties, java.lang.Runnable barrierAction, GenericReductor genericReductor)
          Constructor.
 
Method Summary
 void await(int threadId)
          Called by a party that reaches the barrier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

counter_

protected java.util.concurrent.atomic.AtomicInteger counter_
The central counter variable.


go_

protected volatile boolean go_
Global out flag.

Constructor Detail

CentralBarrier

public CentralBarrier(int numParties,
                      java.lang.Runnable barrierAction,
                      GenericReductor genericReductor)
Constructor.

Parameters:
numParties - the number of parties that must reach the barrier before the barrier is tripped
barrierAction - the command to execute when the barrier is tripped, or null if there is no action
genericReductor - an optional generic reductor

CentralBarrier

public CentralBarrier(int numParties,
                      java.lang.Runnable barrierAction)
Constructor.

Parameters:
numParties - the number of parties that must reach the barrier before the barrier is tripped
barrierAction - the command to execute when the barrier is tripped, or null if there is no action

CentralBarrier

public CentralBarrier(int numParties)
Constructor (if no action is used).

Parameters:
numParties - the number of parties that must reach the barrier before the barrier is tripped
Method Detail

await

public void await(int threadId)
Called by a party that reaches the barrier.

Specified by:
await in interface Barrier
Specified by:
await in class AbstractBarrier
Parameters:
threadId - the ID of the party

jbarrier

Copyright 2010 Patrick Peschlow