Pausing and resuming a caucus

The standard implementation of the Caucus framework provides pause and resume facilities. Pausing a caucus causes all messages sent subsequent to the pause to queue internally. This is useful when a member wants to synchronize shared data among all members of the caucus.

A member pauses a caucus by sending a TStandardCaucusPauseMessage object. All members of the caucus receive the pause message, including the originator--when the originator receives its own message, it knows that the pause is in effect. Messages then queue up internally until the member that originated the pause message issues a TStandardCaucusResumeMessage.

Only the member that pauses a caucus can resume it. If the member that initiated a pause leaves the caucus, the Leave member function automatically triggers a resume message with zero bytes of data, ensuring that the caucus will not stay paused indefinitely.

All messages sent while the caucus is paused are queued, including join and leave messages. The ordering of the internal queue is not guaranteed to match the order in which the caucus members sent the messages. Resuming the caucus, however, sends all messages in the same order in which they were queued.

Pausing a caucus

To pause a caucus:

  1. Construct a TStandardCaucusPauseMessage object on the stack, passing in an alias to the sending caucus member.
  2. Stream data into the pause message object.
    This step is optional; you do not have to send data with a pause message.
  3. Destroy the TStandardCaucusPauseMessage object.
This example does not stream any data into the pause message object.

      {
      TStandardCaucusPauseMessage message( fCaucusMember ) ;
      }

Resuming a caucus

To resume a caucus:

  1. Construct a TStandardCaucusResumeMessage object on the stack using an alias to the sending caucus member.
  2. Stream data into the resume message object.
    This step is optional; as with pause messages, you do not have to send data with a resume message.
  3. Destroy the TStandardCaucusResumeMessage object.
This code sends a zero-byte resume message.

      {
      TStandardCaucusResumeMessage message( fCaucusMember ) ;
      }

[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker