|
@@ -67,8 +67,12 @@ public:
|
|
|
const AllocatorPoolInfo& m_poolInfo;
|
|
|
public:
|
|
|
static oatpp::base::memory::ThreadDistributedMemoryPool& getPool(const AllocatorPoolInfo& info){
|
|
|
- static oatpp::base::memory::ThreadDistributedMemoryPool pool(info.poolName, sizeof(T), info.poolChunkSize);
|
|
|
- return pool;
|
|
|
+ static std::once_flag flag;
|
|
|
+ static oatpp::base::memory::ThreadDistributedMemoryPool *pool = nullptr;
|
|
|
+ std::call_once(flag, [&]() {
|
|
|
+ pool = new oatpp::base::memory::ThreadDistributedMemoryPool(info.poolName, sizeof(T), info.poolChunkSize);
|
|
|
+ });
|
|
|
+ return *pool;
|
|
|
}
|
|
|
public:
|
|
|
PoolSharedObjectAllocator(const AllocatorPoolInfo& info)
|
|
@@ -117,10 +121,15 @@ public:
|
|
|
static oatpp::base::memory::MemoryPool& getPool(const AllocatorPoolInfo& info){
|
|
|
#ifndef OATPP_COMPAT_BUILD_NO_THREAD_LOCAL
|
|
|
static thread_local oatpp::base::memory::MemoryPool pool(info.poolName, sizeof(T), info.poolChunkSize);
|
|
|
+ return pool;
|
|
|
#else
|
|
|
- static oatpp::base::memory::MemoryPool pool(info.poolName, sizeof(T), info.poolChunkSize);
|
|
|
+ static std::once_flag flag;
|
|
|
+ static oatpp::base::memory::MemoryPool *pool = nullptr;
|
|
|
+ std::call_once(flag, [&]() {
|
|
|
+ pool = new oatpp::base::memory::MemoryPool(info.poolName, sizeof(T), info.poolChunkSize);
|
|
|
+ });
|
|
|
+ return *pool;
|
|
|
#endif
|
|
|
- return pool;
|
|
|
}
|
|
|
public:
|
|
|
ThreadLocalPoolSharedObjectAllocator(const AllocatorPoolInfo& info)
|