Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
Static Public Member Functions | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
LockedPoolManager Class Reference

Singleton class to keep track of locked (ie, non-swappable) memory, for use in std::allocator templates. More...

#include <lockedpool.h>

Inheritance diagram for LockedPoolManager:
[legend]
Collaboration diagram for LockedPoolManager:
[legend]

Static Public Member Functions

static LockedPoolManagerInstance ()
 Return the current instance, or create it once.
 

Private Member Functions

 LockedPoolManager (std::unique_ptr< LockedPageAllocator > allocator)
 

Static Private Member Functions

static void CreateInstance ()
 Create a new LockedPoolManager specialized to the OS.
 
static bool LockingFailed ()
 Called when locking fails, warn the user here.
 

Static Private Attributes

static LockedPoolManager_instance = nullptr
 

Additional Inherited Members

- Public Types inherited from LockedPool
typedef bool(* LockingFailed_Callback) ()
 Callback when allocation succeeds but locking fails.
 
- Public Member Functions inherited from LockedPool
 LockedPool (std::unique_ptr< LockedPageAllocator > allocator, LockingFailed_Callback lf_cb_in=nullptr)
 Create a new LockedPool.
 
 ~LockedPool ()
 
 LockedPool (const LockedPool &other)=delete
 
LockedPooloperator= (const LockedPool &)=delete
 
voidalloc (size_t size)
 Allocate size bytes from this arena.
 
void free (void *ptr)
 Free a previously allocated chunk of memory.
 
Stats stats () const
 Get pool usage statistics.
 
- Static Public Attributes inherited from LockedPool
static const size_t ARENA_SIZE = 256 * 1024
 Size of one arena of locked memory.
 
static const size_t ARENA_ALIGN = 16
 Chunk alignment.
 

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 233 of file lockedpool.h.

Constructor & Destructor Documentation

◆ LockedPoolManager()

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

Definition at line 389 of file lockedpool.cpp.

Member Function Documentation

◆ CreateInstance()

void LockedPoolManager::CreateInstance ( )
staticprivate

Create a new LockedPoolManager specialized to the OS.

Definition at line 398 of file lockedpool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Instance()

static LockedPoolManager & LockedPoolManager::Instance ( )
inlinestatic

Return the current instance, or create it once.

Definition at line 236 of file lockedpool.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LockingFailed()

bool LockedPoolManager::LockingFailed ( )
staticprivate

Called when locking fails, warn the user here.

Definition at line 393 of file lockedpool.cpp.

Member Data Documentation

◆ _instance

LockedPoolManager * LockedPoolManager::_instance = nullptr
staticprivate

Definition at line 250 of file lockedpool.h.


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