class ClientBarrierGroups extends AbstractBarrierGroups {

  @Override
  protected BarrierGroupImplementation createBarrierGroup(String name) {

    /**
     * Extending {@link AbstractBarrierGroups} verifies the consistency of the
     * local partition of the barrier group.
     */
    return new BarrierGroupImplementation(name) {

      @Override
      public void addBarrier()
        throws CommunicationException {

        super.addBarrier();

        m_sender.send(new AddBarrierMessage(getName()));
      }

      @Override
      public void removeBarriers(long n) throws CommunicationException {

        super.removeBarriers(n);

        m_sender.send(new RemoveBarriersMessage(getName(), n));
      }

      @Override
      public void addWaiter(BarrierIdentity barrierIdentity)
        throws CommunicationException {

        super.addWaiter(barrierIdentity);

        m_sender.send(new AddWaiterMessage(getName(), barrierIdentity));
      }

      @Override
      public void cancelWaiter(BarrierIdentity barrierIdentity)
        throws CommunicationException {

        super.cancelWaiter(barrierIdentity);

        m_sender.send(new CancelWaiterMessage(getName(), barrierIdentity));
      }
    };
  }

  public  ClientBarrierGroups(Sender sender,
                             MessageDispatchRegistry messageDispatch);

}