mirror of
https://gitee.com/zyjblog/oatpp.git
synced 2024-12-22 22:16:37 +08:00
memory pools: Remove std::call_once.
This commit is contained in:
parent
8a15cb43b1
commit
8a5ad5c88b
3
.gitignore
vendored
3
.gitignore
vendored
@ -46,8 +46,9 @@ srt/build/
|
|||||||
test/build/
|
test/build/
|
||||||
|
|
||||||
# Docker
|
# Docker
|
||||||
|
|
||||||
Dockerfile
|
Dockerfile
|
||||||
|
docker-compose.yaml
|
||||||
|
docker-compose.yml
|
||||||
|
|
||||||
# VS
|
# VS
|
||||||
.vs/
|
.vs/
|
||||||
|
@ -40,12 +40,8 @@ private:
|
|||||||
|
|
||||||
static constexpr v_buff_size SM_STRING_POOL_ENTRY_SIZE = 256;
|
static constexpr v_buff_size SM_STRING_POOL_ENTRY_SIZE = 256;
|
||||||
|
|
||||||
static oatpp::base::memory::ThreadDistributedMemoryPool& getSmallStringPool() {
|
static memory::ThreadDistributedMemoryPool& getSmallStringPool() {
|
||||||
static std::once_flag flag;
|
static auto pool = new memory::ThreadDistributedMemoryPool("Small_String_Pool", SM_STRING_POOL_ENTRY_SIZE, 16);
|
||||||
static oatpp::base::memory::ThreadDistributedMemoryPool *pool = nullptr;
|
|
||||||
std::call_once(flag, []() {
|
|
||||||
pool = new oatpp::base::memory::ThreadDistributedMemoryPool("Small_String_Pool", SM_STRING_POOL_ENTRY_SIZE, 16);
|
|
||||||
});
|
|
||||||
return *pool;
|
return *pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,12 +66,8 @@ public:
|
|||||||
public:
|
public:
|
||||||
const AllocatorPoolInfo& m_poolInfo;
|
const AllocatorPoolInfo& m_poolInfo;
|
||||||
public:
|
public:
|
||||||
static oatpp::base::memory::ThreadDistributedMemoryPool& getPool(const AllocatorPoolInfo& info){
|
static ThreadDistributedMemoryPool& getPool(const AllocatorPoolInfo& info){
|
||||||
static std::once_flag flag;
|
static auto pool = new ThreadDistributedMemoryPool(info.poolName, sizeof(T), info.poolChunkSize);
|
||||||
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;
|
return *pool;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
@ -123,11 +119,7 @@ public:
|
|||||||
static thread_local oatpp::base::memory::MemoryPool pool(info.poolName, sizeof(T), info.poolChunkSize);
|
static thread_local oatpp::base::memory::MemoryPool pool(info.poolName, sizeof(T), info.poolChunkSize);
|
||||||
return pool;
|
return pool;
|
||||||
#else
|
#else
|
||||||
static std::once_flag flag;
|
static auto pool = new MemoryPool(info.poolName, sizeof(T), info.poolChunkSize);
|
||||||
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;
|
return *pool;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -103,11 +103,7 @@ class POOL_NAME { \
|
|||||||
public: \
|
public: \
|
||||||
\
|
\
|
||||||
static oatpp::base::memory::ThreadDistributedMemoryPool& getPool(){ \
|
static oatpp::base::memory::ThreadDistributedMemoryPool& getPool(){ \
|
||||||
static std::once_flag flag; \
|
static auto pool = new oatpp::base::memory::ThreadDistributedMemoryPool(#POOL_NAME"<"#TYPE">", sizeof(TYPE), CHUNK_SIZE); \
|
||||||
static oatpp::base::memory::ThreadDistributedMemoryPool *pool = nullptr; \
|
|
||||||
std::call_once(flag, []() { \
|
|
||||||
pool = new oatpp::base::memory::ThreadDistributedMemoryPool(#POOL_NAME"<"#TYPE">", sizeof(TYPE), CHUNK_SIZE); \
|
|
||||||
}); \
|
|
||||||
return *pool; \
|
return *pool; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
@ -193,11 +189,7 @@ static void operator delete(void* ptr, void* entry) { \
|
|||||||
public: \
|
public: \
|
||||||
\
|
\
|
||||||
static oatpp::base::memory::MemoryPool& getPool(){ \
|
static oatpp::base::memory::MemoryPool& getPool(){ \
|
||||||
static std::once_flag flag; \
|
static auto pool = new oatpp::base::memory::MemoryPool(#POOL_NAME"<"#TYPE">", sizeof(TYPE), CHUNK_SIZE); \
|
||||||
static oatpp::base::memory::MemoryPool *pool = nullptr; \
|
|
||||||
std::call_once(flag, []() { \
|
|
||||||
pool = new oatpp::base::memory::MemoryPool(#POOL_NAME"<"#TYPE">", sizeof(TYPE), CHUNK_SIZE); \
|
|
||||||
}); \
|
|
||||||
return *pool; \
|
return *pool; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
@ -44,12 +44,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
static constexpr v_buff_size BUFFER_SIZE = 4096;
|
static constexpr v_buff_size BUFFER_SIZE = 4096;
|
||||||
private:
|
private:
|
||||||
static oatpp::base::memory::ThreadDistributedMemoryPool& getBufferPool(){
|
static oatpp::base::memory::ThreadDistributedMemoryPool& getBufferPool() {
|
||||||
static std::once_flag flag;
|
static auto pool = new oatpp::base::memory::ThreadDistributedMemoryPool("IOBuffer_Buffer_Pool", BUFFER_SIZE, 16);
|
||||||
static oatpp::base::memory::ThreadDistributedMemoryPool *pool = nullptr;
|
|
||||||
std::call_once(flag, []() {
|
|
||||||
pool = new oatpp::base::memory::ThreadDistributedMemoryPool("IOBuffer_Buffer_Pool", BUFFER_SIZE, 16);
|
|
||||||
});
|
|
||||||
return *pool;
|
return *pool;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
@ -51,12 +51,8 @@ public:
|
|||||||
static const v_buff_size CHUNK_ENTRY_SIZE;
|
static const v_buff_size CHUNK_ENTRY_SIZE;
|
||||||
static const v_buff_size CHUNK_CHUNK_SIZE;
|
static const v_buff_size CHUNK_CHUNK_SIZE;
|
||||||
|
|
||||||
static oatpp::base::memory::ThreadDistributedMemoryPool& getSegemntPool(){
|
static oatpp::base::memory::ThreadDistributedMemoryPool& getSegemntPool() {
|
||||||
static std::once_flag flag;
|
static auto pool = new oatpp::base::memory::ThreadDistributedMemoryPool(CHUNK_POOL_NAME, CHUNK_ENTRY_SIZE, CHUNK_CHUNK_SIZE);
|
||||||
static oatpp::base::memory::ThreadDistributedMemoryPool *pool = nullptr;
|
|
||||||
std::call_once(flag, []() {
|
|
||||||
pool = new oatpp::base::memory::ThreadDistributedMemoryPool(CHUNK_POOL_NAME, CHUNK_ENTRY_SIZE, CHUNK_CHUNK_SIZE);
|
|
||||||
});
|
|
||||||
return *pool;
|
return *pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user