Pyrogenesis  trunk
Public Member Functions | Private Member Functions | Private Attributes | List of all members
OverrunProtector< T > Class Template Reference

OverrunProtector wraps an arbitrary object in isolated page(s) and can detect inadvertent writes to it. More...

#include <overrun_protector.h>

Public Member Functions

 OverrunProtector ()
 
 ~OverrunProtector ()
 
Tget () const
 
void lock () const
 

Private Member Functions

 NONCOPYABLE (OverrunProtector)
 
void unlock () const
 

Private Attributes

T *const object
 

Detailed Description

template<class T>
class OverrunProtector< T >

OverrunProtector wraps an arbitrary object in isolated page(s) and can detect inadvertent writes to it.

this is useful for tracking down memory overruns.

the basic idea is to require users to request access to the object and notify us when done; memory access permission is temporarily granted. (similar in principle to Software Transaction Memory).

since this is quite slow, the protection is disabled unless CONFIG2_ALLOCATORS_OVERRUN_PROTECTION == 1; this avoids having to remove the wrapper code in release builds and re-write when looking for overruns.

example usage: OverrunProtector<T> wrapper; .. T* p = wrapper.get(); // unlock, make ready for use if(!p) // wrapper's one-time alloc of a T- abort(); // instance had failed - can't continue. DoSomethingWith(p); // (read/write access) wrapper.lock(); // disallow further access until next .get() ..

Constructor & Destructor Documentation

◆ OverrunProtector()

template<class T >
OverrunProtector< T >::OverrunProtector ( )
inline

◆ ~OverrunProtector()

template<class T >
OverrunProtector< T >::~OverrunProtector ( )
inline

Member Function Documentation

◆ get()

template<class T >
T* OverrunProtector< T >::get ( ) const
inline

◆ lock()

template<class T >
void OverrunProtector< T >::lock ( ) const
inline

◆ NONCOPYABLE()

template<class T >
OverrunProtector< T >::NONCOPYABLE ( OverrunProtector< T )
private

◆ unlock()

template<class T >
void OverrunProtector< T >::unlock ( ) const
inlineprivate

Member Data Documentation

◆ object

template<class T >
T* const OverrunProtector< T >::object
private

The documentation for this class was generated from the following file: