Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
Singleton class to keep track of locked (ie, non-swappable) memory, for use in std::allocator templates. More...
#include <lockedpool.h>
Static Public Member Functions | |
static LockedPoolManager & | Instance () |
Return the current instance, or create it once. More... | |
Private Member Functions | |
LockedPoolManager (std::unique_ptr< LockedPageAllocator > allocator) | |
Static Private Member Functions | |
static void | CreateInstance () |
Create a new LockedPoolManager specialized to the OS. More... | |
static bool | LockingFailed () |
Called when locking fails, warn the user here. More... | |
Static Private Attributes | |
static LockedPoolManager * | _instance = nullptr |
static std::once_flag | init_flag |
Additional Inherited Members | |
Public Types inherited from LockedPool | |
typedef bool(* | LockingFailed_Callback) () |
Callback when allocation succeeds but locking fails. More... | |
Public Member Functions inherited from LockedPool | |
LockedPool (std::unique_ptr< LockedPageAllocator > allocator, LockingFailed_Callback lf_cb_in=nullptr) | |
Create a new LockedPool. More... | |
~LockedPool () | |
LockedPool (const LockedPool &other)=delete | |
LockedPool & | operator= (const LockedPool &)=delete |
void * | alloc (size_t size) |
Allocate size bytes from this arena. More... | |
void | free (void *ptr) |
Free a previously allocated chunk of memory. More... | |
Stats | stats () const |
Get pool usage statistics. More... | |
Static Public Attributes inherited from LockedPool | |
static const size_t | ARENA_SIZE = 256*1024 |
Size of one arena of locked memory. More... | |
static const size_t | ARENA_ALIGN = 16 |
Chunk alignment. More... | |
Detailed Description
Singleton class to keep track of locked (ie, non-swappable) memory, for use in std::allocator templates.
Some implementations of the STL allocate memory in some constructors (i.e., see MSVC's vector<T> implementation where it allocates 1 byte of memory in the allocator.) Due to the unpredictable order of static initializers, we have to make sure the LockedPoolManager instance exists before any other STL-based objects that use secure_allocator are created. So instead of having LockedPoolManager also be static-initialized, it is created on demand.
Definition at line 209 of file lockedpool.h.
Constructor & Destructor Documentation
◆ LockedPoolManager()
|
explicitprivate |
Definition at line 361 of file lockedpool.cpp.
Member Function Documentation
◆ CreateInstance()
|
staticprivate |
Create a new LockedPoolManager specialized to the OS.
Definition at line 372 of file lockedpool.cpp.
References _instance, and LockedPool::allocator.
Referenced by Instance().
◆ Instance()
|
inlinestatic |
Return the current instance, or create it once.
Definition at line 213 of file lockedpool.h.
References _instance, CreateInstance(), and init_flag.
Referenced by secure_allocator< T >::allocate(), create_secure_allocator(), secure_allocator< T >::deallocate(), pooled_secure_allocator< T >::internal_secure_allocator::free(), pooled_secure_allocator< T >::internal_secure_allocator::malloc(), and RPCLockedMemoryInfo().
◆ LockingFailed()
|
staticprivate |
Called when locking fails, warn the user here.
Definition at line 366 of file lockedpool.cpp.
Member Data Documentation
◆ _instance
|
staticprivate |
Definition at line 227 of file lockedpool.h.
Referenced by CreateInstance(), and Instance().
◆ init_flag
|
staticprivate |
Definition at line 228 of file lockedpool.h.
Referenced by Instance().
The documentation for this class was generated from the following files:
- src/support/lockedpool.h
- src/support/lockedpool.cpp