clang API Documentation
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>
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 () | |
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.
| typedef void(* clang::DelayedCleanupPool::CleanupFn)(void *ptr) |
Definition at line 36 of file DelayedCleanupPool.h.
| clang::DelayedCleanupPool::~DelayedCleanupPool | ( | ) | [inline] |
Definition at line 77 of file DelayedCleanupPool.h.
References doCleanup().
| bool clang::DelayedCleanupPool::delayCleanup | ( | void * | ptr, |
| CleanupFn | fn | ||
| ) | [inline] |
Adds a pointer and its associated cleanup function to be called at a later point.
Definition at line 42 of file DelayedCleanupPool.h.
Referenced by delayDelete(), and delayMemberFunc().
| bool clang::DelayedCleanupPool::delayDelete | ( | T * | ptr | ) | [inline] |
Definition at line 60 of file DelayedCleanupPool.h.
References delayCleanup().
| bool clang::DelayedCleanupPool::delayMemberFunc | ( | T * | ptr | ) | [inline] |
Definition at line 65 of file DelayedCleanupPool.h.
References delayCleanup().
| void clang::DelayedCleanupPool::doCleanup | ( | ) | [inline] |
Definition at line 69 of file DelayedCleanupPool.h.
Referenced by clang::DelayedCleanupPoint::~DelayedCleanupPoint(), and ~DelayedCleanupPool().