Optimizing using batched notification

Often, a single event causes a sender to send several notifications. As a service to receivers, the sender can send these notifications in a batch; that is, as a single notification containing an ordered list of the individual notifications. This allows a receiver to optimize its response to the notifications. For example, a view on a Document framework model might perform a single update for a user action, even though the action causes the model to issue several notifications.

For this to be effective, the sender has to batch notifications where appropriate and the receiver has to request its connection to deliver batched notifications.

A sender creates batched notifications by bracketing calls to Notify with calls to BeginNotification and EndNotification. All notifications issued between these calls are collected and sent, contained in a single instance of TBatchNotification, to receivers that are set up to receive batched notifications.

A receiver sets up to receive batched notifications by calling its connection's SetBatchedNotify member function. Generally, this is done when first setting up the connection and then it is never changed.

Design a receiver explicitly to receive batched notifications. Once a receiver has requested batched notifications, all notifications it receives are batched, whether or not the sender originally batched them. Conversely, a receiver that has not requested batched notifications always receives single notifications, regardless of how the sender sends them. This design allows you to modify the sender's code later: to change its policy about batching notifications without breaking any receivers--those designed to receive batched notifications still do so and those that were not so designed still receive individual notifications.

Normally, a receiver handles batched notifications by setting up an internal state (such as an area for invalidation) and then dispatching the notifications individually using DispatchNotifications. Afterward, the receiver examines the state and takes appropriate action.


[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