CatapultServer  v0.5.0.1 (Elephant)
catapult::thread::MultiServicePool Class Reference

Classes

class  ServiceGroup
 

Public Types

enum  IsolatedPoolMode { IsolatedPoolMode::Enabled, IsolatedPoolMode::Disabled }
 Isolated pool mode. More...
 

Public Member Functions

 MultiServicePool (const std::string &name, size_t numWorkerThreads, IsolatedPoolMode isolatedPoolMode=IsolatedPoolMode::Enabled)
 
 ~MultiServicePool ()
 Destroys the pool. More...
 
size_t numWorkerThreads () const
 Gets the number of active worker threads. More...
 
size_t numServiceGroups () const
 Gets the number of service groups. More...
 
size_t numServices () const
 
std::shared_ptr< ServiceGrouppushServiceGroup (const std::string &name)
 Creates a new service group with name. More...
 
std::shared_ptr< thread::IoThreadPoolpushIsolatedPool (const std::string &name)
 Creates a new isolated thread pool with a default number of threads and name. More...
 
std::shared_ptr< thread::IoThreadPoolpushIsolatedPool (const std::string &name, size_t numWorkerThreads)
 
void shutdown ()
 Safely shuts down the thread pool and its dependent services. More...
 

Static Public Member Functions

static constexpr size_t DefaultPoolConcurrency ()
 A default pool concurrency level based on the local hardware configuration. More...
 

Private Member Functions

template<typename TService >
auto registerService (const std::shared_ptr< TService > &pService, const std::string &serviceName)
 

Static Private Member Functions

static std::shared_ptr< thread::IoThreadPoolCreateThreadPool (size_t numWorkerThreads, const std::string &name)
 
template<typename T >
static void WaitForLastReference (const std::shared_ptr< T > &pVoid)
 

Private Attributes

std::string m_name
 
IsolatedPoolMode m_isolatedPoolMode
 
size_t m_numTotalIsolatedPoolThreads
 
size_t m_numServiceGroups
 
std::shared_ptr< thread::IoThreadPoolm_pPool
 
std::vector< std::shared_ptr< ServiceGroup > > m_serviceGroups
 
std::vector< actionm_shutdownFunctions
 

Detailed Description

Manages a primary thread pool with dependent service groups and secondary isolated thread pools.

Note
Services are shutdown in reverse order of registration.

Member Enumeration Documentation

◆ IsolatedPoolMode

Isolated pool mode.

Enumerator
Enabled 

Sub pool isolation is enabled.

Disabled 

Sub pool isolation is disabled.

Constructor & Destructor Documentation

◆ MultiServicePool()

catapult::thread::MultiServicePool::MultiServicePool ( const std::string &  name,
size_t  numWorkerThreads,
IsolatedPoolMode  isolatedPoolMode = IsolatedPoolMode::Enabled 
)
inline

Creates a pool with the specified number of threads (numWorkerThreads) and name with optional isolated pool mode (isolatedPoolMode).

Note
If numWorkerThreads is 0, a default number of threads will be used.

◆ ~MultiServicePool()

catapult::thread::MultiServicePool::~MultiServicePool ( )
inline

Destroys the pool.

Here is the call graph for this function:

Member Function Documentation

◆ CreateThreadPool()

static std::shared_ptr<thread::IoThreadPool> catapult::thread::MultiServicePool::CreateThreadPool ( size_t  numWorkerThreads,
const std::string &  name 
)
inlinestaticprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DefaultPoolConcurrency()

static constexpr size_t catapult::thread::MultiServicePool::DefaultPoolConcurrency ( )
inlinestaticconstexpr

A default pool concurrency level based on the local hardware configuration.

Here is the caller graph for this function:

◆ numServiceGroups()

size_t catapult::thread::MultiServicePool::numServiceGroups ( ) const
inline

Gets the number of service groups.

Here is the caller graph for this function:

◆ numServices()

size_t catapult::thread::MultiServicePool::numServices ( ) const
inline

Gets the number of services.

Note
This accessor is NOT threadsafe.
Here is the call graph for this function:

◆ numWorkerThreads()

size_t catapult::thread::MultiServicePool::numWorkerThreads ( ) const
inline

Gets the number of active worker threads.

Here is the caller graph for this function:

◆ pushIsolatedPool() [1/2]

std::shared_ptr<thread::IoThreadPool> catapult::thread::MultiServicePool::pushIsolatedPool ( const std::string &  name)
inline

Creates a new isolated thread pool with a default number of threads and name.

Here is the call graph for this function:

◆ pushIsolatedPool() [2/2]

std::shared_ptr<thread::IoThreadPool> catapult::thread::MultiServicePool::pushIsolatedPool ( const std::string &  name,
size_t  numWorkerThreads 
)
inline

Creates a new isolated thread pool with the specified number of threads (numWorkerThreads) and name.

Note
If numWorkerThreads is 0, a default number of threads will be used.
Here is the call graph for this function:

◆ pushServiceGroup()

std::shared_ptr<ServiceGroup> catapult::thread::MultiServicePool::pushServiceGroup ( const std::string &  name)
inline

Creates a new service group with name.

Here is the call graph for this function:

◆ registerService()

template<typename TService >
auto catapult::thread::MultiServicePool::registerService ( const std::shared_ptr< TService > &  pService,
const std::string &  serviceName 
)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ shutdown()

void catapult::thread::MultiServicePool::shutdown ( )
inline

Safely shuts down the thread pool and its dependent services.

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

◆ WaitForLastReference()

template<typename T >
static void catapult::thread::MultiServicePool::WaitForLastReference ( const std::shared_ptr< T > &  pVoid)
inlinestaticprivate
Here is the caller graph for this function:

Member Data Documentation

◆ m_isolatedPoolMode

IsolatedPoolMode catapult::thread::MultiServicePool::m_isolatedPoolMode
private

◆ m_name

std::string catapult::thread::MultiServicePool::m_name
private

◆ m_numServiceGroups

size_t catapult::thread::MultiServicePool::m_numServiceGroups
private

◆ m_numTotalIsolatedPoolThreads

size_t catapult::thread::MultiServicePool::m_numTotalIsolatedPoolThreads
private

◆ m_pPool

std::shared_ptr<thread::IoThreadPool> catapult::thread::MultiServicePool::m_pPool
private

◆ m_serviceGroups

std::vector<std::shared_ptr<ServiceGroup> > catapult::thread::MultiServicePool::m_serviceGroups
private

◆ m_shutdownFunctions

std::vector<action> catapult::thread::MultiServicePool::m_shutdownFunctions
private

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