|
KiCad PCB EDA Suite
|
A wrapper for static data that should not be destroyed at program exit. More...
#include <leak_at_exit.h>
Public Member Functions | |
| LEAK_AT_EXIT () | |
| LEAK_AT_EXIT (const LEAK_AT_EXIT &)=delete | |
| LEAK_AT_EXIT & | operator= (const LEAK_AT_EXIT &)=delete |
| LEAK_AT_EXIT (LEAK_AT_EXIT &&)=delete | |
| LEAK_AT_EXIT & | operator= (LEAK_AT_EXIT &&)=delete |
| T & | Get () |
| Access the underlying object, creating it on first call. | |
| T & | operator* () |
| T * | operator-> () |
| operator T& () | |
Private Attributes | |
| T * | m_instance |
| std::once_flag | m_initFlag |
A wrapper for static data that should not be destroyed at program exit.
Usage: // Instead of: static std::map<wxString, Data> GlobalData;
// Use: static LEAK_AT_EXIT<std::map<wxString, Data>> GlobalData;
The wrapped object is heap-allocated on first access and never freed. This avoids running potentially expensive destructors during static destruction, speeding up program exit.
Each LEAK_AT_EXIT instance has its own storage, so multiple static variables of the same type will each get their own heap allocation.
Thread-safe for concurrent first access (uses std::call_once).
Definition at line 67 of file leak_at_exit.h.
|
inline |
Definition at line 70 of file leak_at_exit.h.
References m_instance.
Referenced by LEAK_AT_EXIT(), LEAK_AT_EXIT(), operator=(), and operator=().
|
delete |
References LEAK_AT_EXIT().
|
delete |
References LEAK_AT_EXIT().
|
inline |
Access the underlying object, creating it on first call.
The object is intentionally never destroyed.
Definition at line 82 of file leak_at_exit.h.
References LSAN_IGNORE, m_initFlag, m_instance, and T.
Referenced by LEAK_AT_EXIT< std::map< wxString, LIB_DATA > >::operator std::map< wxString, LIB_DATA > &(), operator*(), and operator->().
|
inline |
Definition at line 97 of file leak_at_exit.h.
|
inline |
Definition at line 93 of file leak_at_exit.h.
|
inline |
Definition at line 94 of file leak_at_exit.h.
|
delete |
References LEAK_AT_EXIT().
|
delete |
References LEAK_AT_EXIT().
|
private |
Definition at line 101 of file leak_at_exit.h.
Referenced by Get().
|
private |
Definition at line 100 of file leak_at_exit.h.
Referenced by Get(), and LEAK_AT_EXIT().