7.1 Overview

I l @ ve RuBoard

Section 5.1 discussed server concurrency dimensions, with the reactive server on page 106 being one of the design choices. The reactive server model can be thought of as "lightweight multitasking," where a single-threaded server communicates with multiple clients in a round- robin manner without introducing the overhead and complexity of threading and synchronization mechanisms. This server concurrency strategy uses an event loop that examines and reacts to events from its clients continuously. An event loop demultiplexes input from various event sources so they can be processed in an orderly way.

Event sources in networked applications are primarily socket handles. The most portable synchronous event demultiplexer for socket handles is the select() function and its handle sets, discussed on page 125 in Section 6.1. This chapter describes the following classes that can be applied to simplify and optimize the use of these facilities in reactive servers:

ACE Class/Method Description
ACE_Handle_Set Encapsulates an fd_set and the common operations that manipulate it.
ACE_Handle_Set_Iterator Provides a portable and efficient mechanism for iterating through the set of active handles in an ACE_Handle_Set object.
ACE::select() Simplify the most common uses of select() and enhance its portability.

The interfaces of the ACE_Handle_Set and ACE_Handle_Set_Iterator classes are shown in Figure 7.1. These wrapper facades provide the following benefits:

Figure 7.1. ACE_Handle_Set & ACE_Handle_Set_Iterator Class Diagrams

  • Ensure portability across OS platforms. The ACE_Handle_Set and ACE_Handle_Set_Iterator classes can be used on all OS platforms that support select() and fd_set . These classes simplify the correct use of I/O handles to demultiplex network events synchronously.

  • Iterate through the set of active handles efficiently without compromising portability. Iterating through the set of active handles efficiently is an important factor in enhancing the performance of reactive server event loops . The need to optimize event loop performance often tempts programmers to examine the internals of fd_set to find ways to scan them more efficiently. The ACE_Handle_Set_Iterator is highly optimized to alleviate the need for networked applications to rely on internal fd_set representations.

The ACE::select() wrapper methods encapsulate the select() system function and use the ACE_Handle_Set class to simplify handle passing. A reactive version of the logging server is used to illustrate how these ACE wrappers can simplify networked application programming.

I l @ ve RuBoard


C++ Network Programming
C++ Network Programming, Volume I: Mastering Complexity with ACE and Patterns
ISBN: 0201604647
EAN: 2147483647
Year: 2001
Pages: 101

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net