CatapultServer
v0.5.0.1 (Elephant)
|
Go to the documentation of this file.
29 namespace catapult {
namespace thread {
59 ServiceGroup(
const std::shared_ptr<thread::IoThreadPool>& pPool,
const std::string& name)
72 template<
typename TService>
88 template<
typename TFactory,
typename... TArgs>
91 auto pService = factory(
m_pPool, std::forward<TArgs>(args)...);
109 std::shared_ptr<thread::IoThreadPool>
m_pPool;
157 template<
typename TService>
158 auto registerService(
const std::shared_ptr<TService>& pService,
const std::string& serviceName) {
163 pService->shutdown();
173 auto pGroup = std::make_shared<ServiceGroup>(
m_pPool,
m_name +
"::" + name);
188 class PoolServiceAdapter {
190 explicit PoolServiceAdapter(
const std::shared_ptr<thread::IoThreadPool>& pPool) :
m_pPool(pPool)
200 std::shared_ptr<thread::IoThreadPool>
m_pPool;
208 registerService(std::make_shared<PoolServiceAdapter>(pPool), name +
" (isolated pool)");
241 return std::move(pPool);
246 volatile long useCount;
247 while (1 < (useCount = pVoid.use_count()))
248 std::this_thread::yield();
256 std::shared_ptr<thread::IoThreadPool>
m_pPool;
size_t m_numTotalIsolatedPoolThreads
Definition: MultiServicePool.h:254
std::vector< action > m_shutdownFunctions
Definition: MultiServicePool.h:112
#define CATAPULT_LOG(SEV)
Writes a log entry to the default logger with SEV severity.
Definition: Logging.h:340
static std::shared_ptr< thread::IoThreadPool > CreateThreadPool(size_t numWorkerThreads, const std::string &name)
Definition: MultiServicePool.h:237
std::vector< action > m_shutdownFunctions
Definition: MultiServicePool.h:258
def debug(*args)
Definition: Parser.py:46
std::shared_ptr< ServiceGroup > pushServiceGroup(const std::string &name)
Creates a new service group with name.
Definition: MultiServicePool.h:172
size_t numWorkerThreads() const
Gets the number of active worker threads.
Definition: MultiServicePool.h:136
auto pushService(TFactory factory, TArgs &&... args)
Creates a new service by calling factory with args service arguments.
Definition: MultiServicePool.h:89
auto registerService(const std::shared_ptr< TService > &pService)
Registers an externally created service (pService) for cleanup.
Definition: MultiServicePool.h:73
static constexpr size_t DefaultPoolConcurrency()
A default pool concurrency level based on the local hardware configuration.
Definition: MultiServicePool.h:45
std::shared_ptr< thread::IoThreadPool > m_pPool
Definition: MultiServicePool.h:256
void shutdown()
Safely shuts down the service group.
Definition: MultiServicePool.h:96
std::vector< std::shared_ptr< void > > m_services
Definition: MultiServicePool.h:111
Definition: MultiServicePool.h:33
std::shared_ptr< thread::IoThreadPool > pushIsolatedPool(const std::string &name)
Creates a new isolated thread pool with a default number of threads and name.
Definition: MultiServicePool.h:181
std::shared_ptr< thread::IoThreadPool > m_pPool
Definition: MultiServicePool.h:109
Sub pool isolation is enabled.
std::unique_ptr< IoThreadPool > CreateIoThreadPool(size_t numWorkerThreads, const char *name)
Definition: IoThreadPool.cpp:146
void shutdown()
Safely shuts down the thread pool and its dependent services.
Definition: MultiServicePool.h:215
std::shared_ptr< thread::IoThreadPool > pushIsolatedPool(const std::string &name, size_t numWorkerThreads)
Definition: MultiServicePool.h:187
ServiceGroup(const std::shared_ptr< thread::IoThreadPool > &pPool, const std::string &name)
Creates a group around pPool and name.
Definition: MultiServicePool.h:59
Definition: MultiServicePool.h:56
size_t numServices() const
Gets the number of services.
Definition: MultiServicePool.h:66
~MultiServicePool()
Destroys the pool.
Definition: MultiServicePool.h:130
auto registerService(const std::shared_ptr< TService > &pService, const std::string &serviceName)
Definition: MultiServicePool.h:158
def info(*args)
Definition: forwardsValidation.py:12
size_t numServiceGroups() const
Gets the number of service groups.
Definition: MultiServicePool.h:141
IsolatedPoolMode
Isolated pool mode.
Definition: MultiServicePool.h:36
std::string m_name
Definition: MultiServicePool.h:110
size_t m_numServiceGroups
Definition: MultiServicePool.h:255
MultiServicePool(const std::string &name, size_t numWorkerThreads, IsolatedPoolMode isolatedPoolMode=IsolatedPoolMode::Enabled)
Definition: MultiServicePool.h:121
Definition: AddressExtractionExtension.cpp:28
static void WaitForLastReference(const std::shared_ptr< T > &pVoid)
Definition: MultiServicePool.h:245
Sub pool isolation is disabled.
size_t numServices() const
Definition: MultiServicePool.h:147
std::vector< std::shared_ptr< ServiceGroup > > m_serviceGroups
Definition: MultiServicePool.h:257
std::string m_name
Definition: MultiServicePool.h:252
IsolatedPoolMode m_isolatedPoolMode
Definition: MultiServicePool.h:253