Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | 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 ()
 
Tget () const
 
void lock () const
 

Public Attributes

 __pad0__: object(new T()) { lock()
 

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() ..

Definition at line 52 of file overrun_protector.h.

Constructor & Destructor Documentation

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

Definition at line 66 of file overrun_protector.h.

Member Function Documentation

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

Definition at line 77 of file overrun_protector.h.

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

Definition at line 83 of file overrun_protector.h.

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

Definition at line 91 of file overrun_protector.h.

Member Data Documentation

template<class T>
OverrunProtector< T >::__pad0__

Definition at line 63 of file overrun_protector.h.

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

Definition at line 98 of file overrun_protector.h.


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