AIStatefulTask ‐ Asynchronous, Stateful Task Scheduler library.

Threads-like task objects evolving through user-defined states.

Public Member Functions | Static Public Member Functions | List of all members
statefultask::DefaultMemoryPagePool< MPP > Class Template Reference

Detailed Description

template<typename MPP = utils::MemoryPagePool>
class statefultask::DefaultMemoryPagePool< MPP >

The memory pool for all other memory pools.

DefaultMemoryPagePool is a globally accessible MemoryPagePool singleton, but with a life time equal of that of main(). The Default-part refers to the fact that most memory pools, if not all, of a process can use this singleton as their MemoryPagePool. Unless you know what you are doing you're advised to use the default constructor and have all memory pools that are based on an utils::MemoryPagePool use AIMemoryPagePool::instance() .

DefaultMemoryPagePool must be initialized at the start of main before using anything else from statefultask.

Recommended usage,

int main()
{
Debug(NAMESPACE_DEBUG::init();
AIMemoryPagePool mpp; // Add this line at the top of main.
...
}
Definition: DefaultMemoryPagePool.h:116

The above line is equivalent to one of

// The curly braces are required,
// unless you pass at least one argument,
// or specify the (default) template parameter explicitly.

In all cases AIMemoryPagePool::instance() becomes usable, which is currently only required when using AIStatefulTaskMutex (hence anything from filelock-task).

Fine tuning is possible by passing the constructor arguments of a MemoryPagePool to DefaultMemoryPagePool, or to derive your own class from MemoryPagePool and pass that to DefaultMemoryPagePool as template argument. For example,

default_memory_page_pool(constructor arguments of MyMPP);

where MyMPP must be derived from utils::MemoryPagePool.

#include <DefaultMemoryPagePool.h>

Inheritance diagram for statefultask::DefaultMemoryPagePool< MPP >:
Inheritance graph
[legend]
Collaboration diagram for statefultask::DefaultMemoryPagePool< MPP >:
Collaboration graph
[legend]

Public Member Functions

 DefaultMemoryPagePool (size_t block_size=0x8000, utils::MemoryPagePool::blocks_t minimum_chunk_size=0, utils::MemoryPagePool::blocks_t maximum_chunk_size=0)
 Constructor with the same (default) arguments as utils::MemoryPagePool.
 
template<typename... ArgT>
 DefaultMemoryPagePool (ArgT &&... args)
 

Static Public Member Functions

static utils::MemoryPagePool & instance ()
 

Constructor & Destructor Documentation

◆ DefaultMemoryPagePool()

template<typename MPP = utils::MemoryPagePool>
template<typename... ArgT>
statefultask::DefaultMemoryPagePool< MPP >::DefaultMemoryPagePool ( ArgT &&...  args)
inline

Constructor to be used for non-default template parameter MPP when that class takes different arguments than utils::MemoryPagePool.

Note that MPP still must be derived from utils::MemoryPagePool.

Member Function Documentation

◆ instance()

template<typename MPP = utils::MemoryPagePool>
static utils::MemoryPagePool & statefultask::DefaultMemoryPagePool< MPP >::instance ( )
inlinestatic

Returns a reference to the default utils::MemoryPagePool.

This is the singleton that is initialized at the top of main().

See also
DefaultMemoryPagePool

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