Bitcoin
Static Public Member Functions | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
LockedPoolManager Class Reference

#include <lockedpool.h>

Inheritance diagram for LockedPoolManager:
LockedPool

Static Public Member Functions

static LockedPoolManagerInstance ()
 

Private Member Functions

 LockedPoolManager (std::unique_ptr< LockedPageAllocator > allocator)
 

Static Private Member Functions

static void CreateInstance ()
 
static bool LockingFailed ()
 

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) ()
 
- Public Member Functions inherited from LockedPool
 LockedPool (std::unique_ptr< LockedPageAllocator > allocator, LockingFailed_Callback lf_cb_in=nullptr)
 
 ~LockedPool ()
 
 LockedPool (const LockedPool &other)=delete
 
LockedPooloperator= (const LockedPool &)=delete
 
void * alloc (size_t size)
 
void free (void *ptr)
 
Stats stats () const
 
- Static Public Attributes inherited from LockedPool
static const size_t ARENA_SIZE = 256*1024
 
static const size_t ARENA_ALIGN = 16
 

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.

Constructor & Destructor Documentation

◆ LockedPoolManager()

LockedPoolManager::LockedPoolManager ( std::unique_ptr< LockedPageAllocator allocator)
explicitprivate

Member Function Documentation

◆ CreateInstance()

void LockedPoolManager::CreateInstance ( )
staticprivate

Create a new LockedPoolManager specialized to the OS

◆ Instance()

static LockedPoolManager& LockedPoolManager::Instance ( )
inlinestatic

Return the current instance, or create it once

◆ LockingFailed()

bool LockedPoolManager::LockingFailed ( )
staticprivate

Called when locking fails, warn the user here

Member Data Documentation

◆ _instance

LockedPoolManager * LockedPoolManager::_instance = nullptr
staticprivate

◆ init_flag

std::once_flag LockedPoolManager::init_flag
staticprivate

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