next up previous contents
Next: 2.4.6.1 Resource allocator C++ Up: 2.4 System resources Previous: 2.4.5.1 Navigation C++ source

2.4.6 Resource Allocators

Allocators implement resource unit allocation and are responsible for initiating resource revocation when no more resource units are available.

<Off allocator. >= (U->)
// A resource allocator.
//
class off_Allocator { 
protected: 
  <Other protected members of off_Allocator. >
public:
  <Other public methods of off_Allocator. >
};

Defines off_Allocator (links are to index).

We could have defined a resource allocation interface at this point, but doing so would mean that explicit type casts (prone to errors) would be necessary on each resource allocation. Instead, what we do is to build a hierarchy using the Allocator class as a base. That hierarchy uses a void pointer based resource allocation interface which is wrapped by type-safe interfaces. In that way we avoid code duplication (due to template instantiations), dynamic binding and type information loss.



 

Francisco J. Ballesteros
1998-05-25