Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Threads Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

2.6 Smart Pointer Package

2.6.1 Description

The Smart Pointer package includes a generic singleton template class, a simple pointer wrapper, and two varieties of thread-safe reference-counted pointers. The classes that provide these features are shown in Figure 8. The Smart Pointer package also provides the Threads Module with the base classes for handle-body implementation, as shown in Figure 9.

See Chapter 7 of the Threads Module User's Guide for a complete information on how to use the Smart Pointer package.

2.6.2 Smart Pointer Class Hierarchy

Figure 8: Smart Pointer class hierarchy

The classes in the hierarchy include formal template parameters that represent the types of associated objects. These parameters include:

Body -- The type of the pointed-to object

Counter -- The type of the reference-counter

Mutex -- The type of the synchronization mechanism

Figure 9: Handle-body base classes

2.6.3 Index of Smart Pointer Classes

Table 6 contains an alphabetical listing of the public classes and global functions and macros in the Smart Pointer package.

Table 6: Index of Smart Pointer classes 

Class Name Description

RWAtomicCounter

A class for maintaining a reference count. More efficient than RWTCounter<RWMutexLock> where possible.

RWBodyBase

Base class for body classes.

RWHandleBase

Base class for handle classes.

RWSafeCounter

A typedef that implements the multithread-safe reference-counter, which can be used as the counter template parameter for RWTCountingPointer.

RWTCountedPointer<Body>

A smart pointer class that is intended for use as a handle to a reference-counting body.

RWTCounter<Mutex>

A class for maintaining a reference count. Uses the template type as a lock for atomicity.

RWTCountingBody<Mutex>

A base class for classes that must maintain a reference count.

RWTCountingPointer<Body, Counter=RWSafeCounter>

Defines a reference-counted pointer that provides reference counting semantics for objects that do not directly support reference counting.

RWTOnlyPointer<Body>

An abstraction that simplifies the use of pointers referring to objects on the heap. It doesn't do reference-counting on the body; rather, it is based on the idea of strict ownership semantics.

RWTPointer<Body>

Base class for the smart-pointer classes in the pointer package.

RWTSingleton<T>

Ensures that a class has only one instance, and provides a global point of access to it.

RWUnsafeCounter

A typedef that implements an unsafe counter that can be used for reference counting where multithread safety is not required. This typedef can be used as the counter template parameter for RWTCountingPointer.



Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.