jbarrier

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

java.lang.Object
  extended by edu.bonn.cs.net.jbarrier.barrier.AbstractBarrier
All Implemented Interfaces:
Barrier
Direct Known Subclasses:
ButterflyBarrier, CentralBarrier, DisseminationBarrier, StaticTreeBarrier, TournamentBarrier

public abstract class AbstractBarrier
extends java.lang.Object
implements Barrier

Abstract base class for all barrier implementations of this package. Barriers extending this class can have an associated (global) action, specified as a Runnable, which will be executed by one party when all parties have reached the barrier. Also, arbitrary global reductions are supported with the help of a GenericReductor object.

With respect to memory consistency, just like with the CyclicBarrier, actions in a thread prior to calling await(int) happen-before actions that are part of the barrier action, which in turn happen-before actions following a successful return from await(int) in other threads.

At this point, there is not much of an error handling if, e.g., threads get interrupted during the barrier. A well-defined error handling, such as the BrokenBarrierException used by the CyclicBarrier, may be added in future versions.

Version:
1.0
Author:
Patrick Peschlow, Ivan Castilla Rodriguez

Field Summary
protected  java.lang.Runnable action_
          The command to execute when the barrier is tripped, or null if there is no action.
protected  GenericReductor genericReductor_
          An optional generic reduction operator.
protected  int numParties_
          The number of parties taking part in the barrier.
 
Constructor Summary
protected AbstractBarrier(int numParties, java.lang.Runnable action, GenericReductor genericReductor)
          Creates a new AbstractBarrier that will trip when the given number of parties are waiting upon it.
 
Method Summary
abstract  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

numParties_

protected final int numParties_
The number of parties taking part in the barrier.


action_

protected final java.lang.Runnable action_
The command to execute when the barrier is tripped, or null if there is no action.


genericReductor_

protected final GenericReductor genericReductor_
An optional generic reduction operator.

Constructor Detail

AbstractBarrier

protected AbstractBarrier(int numParties,
                          java.lang.Runnable action,
                          GenericReductor genericReductor)
Creates a new AbstractBarrier that will trip when the given number of parties are waiting upon it.

Parameters:
numParties - the number of parties that must reach the barrier before the barrier is tripped
action - the command to execute when the barrier is tripped, or null if there is no action
genericReductor - an optional generic reductor
Throws:
java.lang.IllegalArgumentException - if numParties is less than 2
Method Detail

await

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

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

jbarrier

Copyright 2010 Patrick Peschlow