clang API Documentation

Public Types | Public Member Functions
clang::DelayedCleanupPool Class Reference

Gathers pairs of pointer-to-object/pointer-to-cleanup-function allowing the cleanup functions to get called (with the pointer as parameter) at specific points. More...

#include <DelayedCleanupPool.h>

List of all members.

Public Types

typedef void(* CleanupFn )(void *ptr)

Public Member Functions

bool delayCleanup (void *ptr, CleanupFn fn)
 Adds a pointer and its associated cleanup function to be called at a later point.
template<typename T >
bool delayDelete (T *ptr)
template<typename T , void(T::*)() Fn>
bool delayMemberFunc (T *ptr)
void doCleanup ()
 ~DelayedCleanupPool ()

Detailed Description

Gathers pairs of pointer-to-object/pointer-to-cleanup-function allowing the cleanup functions to get called (with the pointer as parameter) at specific points.

The use case is to simplify clean-up of certain resources that, while their lifetime is well-known and restricted, cleaning them up manually is easy to miss and cause a leak.

The same pointer can be added multiple times; its clean-up function will only be called once.

Definition at line 34 of file DelayedCleanupPool.h.


Member Typedef Documentation

typedef void(* clang::DelayedCleanupPool::CleanupFn)(void *ptr)

Definition at line 36 of file DelayedCleanupPool.h.


Constructor & Destructor Documentation

clang::DelayedCleanupPool::~DelayedCleanupPool ( ) [inline]

Definition at line 77 of file DelayedCleanupPool.h.

References doCleanup().


Member Function Documentation

bool clang::DelayedCleanupPool::delayCleanup ( void *  ptr,
CleanupFn  fn 
) [inline]

Adds a pointer and its associated cleanup function to be called at a later point.

Returns:
false if the pointer is already added, true otherwise.

Definition at line 42 of file DelayedCleanupPool.h.

Referenced by delayDelete(), and delayMemberFunc().

template<typename T >
bool clang::DelayedCleanupPool::delayDelete ( T *  ptr) [inline]

Definition at line 60 of file DelayedCleanupPool.h.

References delayCleanup().

template<typename T , void(T::*)() Fn>
bool clang::DelayedCleanupPool::delayMemberFunc ( T *  ptr) [inline]

Definition at line 65 of file DelayedCleanupPool.h.

References delayCleanup().

void clang::DelayedCleanupPool::doCleanup ( ) [inline]

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