Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

3.3 Threading Class Hierarchies

The Threading package includes the runnable classes and the thread attribute classes.

3.3.1 The Runnable Class Hierarchy

The Threading package runnable objects are implemented using a common C++ design technique called the handle-body idiom. Each runnable instance consists of a protected body instance with one or more public handle instances that reference it. The hierarchy of runnable classes is shown in Figure 2.

A runnable object is reference-counted. Each runnable body instance keeps a count of the number of handles that currently reference it. A runnable object is deleted when the last handle that references the body is deleted.

The public interface for a runnable is included in its handle classes. Many of the public functions in a handle simply forward control to a corresponding protected function in the body class.

You can find additional information regarding the handle-body idiom and reference-counting in the Smart Pointer package.

Figure 2 -- Runnable and thread pool class hierarchy

3.3.1.1 Runnable Handle Classes

Many runnable objects supply two different handle classes-one that defines an interface intended for use by outside threads and one that defines an interface that can only be used by the thread running inside the runnable object. Other runnable functions do not have inside or outside access restrictions and are defined in both the internal and external handle classes.

3.3.1.2 Runnable Body Classes

The runnable body classes are not publicly accessible. These classes can only be accessed and constructed using functions defined by the runnable handle classes.

3.3.1.3 Thread Pool Class

The thread pool handle class RWThreadPool is not a runnable. It is included in this hierarchy because of its relationship to RWServerPool.

3.3.2 The Attribute Class Hierarchy

All of the thread attributes supported by the Threading package are captured within instances of the RWThreadAttribute class, as shown in Figure 3.

Figure 3 -- Thread attribute class hierarchy

3.3.3 The IOU Class in the Threading Package

Figure 4 shows the IOU class hierarchy. All but one of these classes are in the Interthread Communication package, which implements the framework for the IOU functionality. The hierarchy is duplicated here, because the piece that makes IOUs usable is the Threading package class RWTThreadEscrowImp. This class has the mechanisms for synchronizing multithread access to the result and blocking threads that have attempted to redeem the result before it has been supplied.

Figure 4 -- IOU class hierarchy


Previous fileTop of DocumentContentsIndexNext file

©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.