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

Public Member Functions

 ServiceGroup (const std::shared_ptr< thread::IoThreadPool > &pPool, const std::string &name)
 Creates a group around pPool and name. More...
 
size_t numServices () const
 Gets the number of services. More...
 
template<typename TService >
auto registerService (const std::shared_ptr< TService > &pService)
 Registers an externally created service (pService) for cleanup. More...
 
template<typename TFactory , typename... TArgs>
auto pushService (TFactory factory, TArgs &&... args)
 Creates a new service by calling factory with args service arguments. More...
 
void shutdown ()
 Safely shuts down the service group. More...
 

Private Attributes

std::shared_ptr< thread::IoThreadPoolm_pPool
 
std::string m_name
 
std::vector< std::shared_ptr< void > > m_services
 
std::vector< actionm_shutdownFunctions
 

Detailed Description

A group of services that should be shutdown together and might be interdependent.

Note
AsyncTcpServer and accept handlers (PacketReaders, PacketWriters) have such a shutdown requirement because AsyncTcpServer includes a shared_ptr to itself as part of its accepted PacketSocket, which is then kept alive by the accept handlers until they are also shutdown.

Constructor & Destructor Documentation

◆ ServiceGroup()

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

Creates a group around pPool and name.

Member Function Documentation

◆ numServices()

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

Gets the number of services.

◆ pushService()

template<typename TFactory , typename... TArgs>
auto catapult::thread::MultiServicePool::ServiceGroup::pushService ( TFactory  factory,
TArgs &&...  args 
)
inline

Creates a new service by calling factory with args service arguments.

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

◆ registerService()

template<typename TService >
auto catapult::thread::MultiServicePool::ServiceGroup::registerService ( const std::shared_ptr< TService > &  pService)
inline

Registers an externally created service (pService) for cleanup.

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

◆ shutdown()

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

Safely shuts down the service group.

Here is the call graph for this function:

Member Data Documentation

◆ m_name

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

◆ m_pPool

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

◆ m_services

std::vector<std::shared_ptr<void> > catapult::thread::MultiServicePool::ServiceGroup::m_services
private

◆ m_shutdownFunctions

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

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