mirror of
https://gitee.com/zyjblog/oatpp.git
synced 2024-12-22 22:16:37 +08:00
Merge pull request #314 from pcapdump/issue_308
Issue #308: oatpp::base::memory::MemoryPool::freeByEntryHeader()]: Invalid EntryHeader
This commit is contained in:
commit
8a15cb43b1
@ -41,8 +41,12 @@ private:
|
||||
static constexpr v_buff_size SM_STRING_POOL_ENTRY_SIZE = 256;
|
||||
|
||||
static oatpp::base::memory::ThreadDistributedMemoryPool& getSmallStringPool() {
|
||||
static oatpp::base::memory::ThreadDistributedMemoryPool pool("Small_String_Pool", SM_STRING_POOL_ENTRY_SIZE, 16);
|
||||
return pool;
|
||||
static std::once_flag flag;
|
||||
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;
|
||||
}
|
||||
|
||||
static v_buff_size getSmStringBaseSize() {
|
||||
|
@ -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);
|
||||
#else
|
||||
static oatpp::base::memory::MemoryPool pool(info.poolName, sizeof(T), info.poolChunkSize);
|
||||
#endif
|
||||
return pool;
|
||||
#else
|
||||
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
|
||||
}
|
||||
public:
|
||||
ThreadLocalPoolSharedObjectAllocator(const AllocatorPoolInfo& info)
|
||||
|
@ -103,8 +103,12 @@ class POOL_NAME { \
|
||||
public: \
|
||||
\
|
||||
static oatpp::base::memory::ThreadDistributedMemoryPool& getPool(){ \
|
||||
static oatpp::base::memory::ThreadDistributedMemoryPool pool(#POOL_NAME"<"#TYPE">", sizeof(TYPE), CHUNK_SIZE); \
|
||||
return pool; \
|
||||
static std::once_flag flag; \
|
||||
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; \
|
||||
} \
|
||||
\
|
||||
}; \
|
||||
@ -189,8 +193,12 @@ static void operator delete(void* ptr, void* entry) { \
|
||||
public: \
|
||||
\
|
||||
static oatpp::base::memory::MemoryPool& getPool(){ \
|
||||
static oatpp::base::memory::MemoryPool pool(#POOL_NAME"<"#TYPE">", sizeof(TYPE), CHUNK_SIZE); \
|
||||
return pool; \
|
||||
static std::once_flag flag; \
|
||||
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; \
|
||||
} \
|
||||
\
|
||||
};
|
||||
|
@ -45,8 +45,12 @@ public:
|
||||
static constexpr v_buff_size BUFFER_SIZE = 4096;
|
||||
private:
|
||||
static oatpp::base::memory::ThreadDistributedMemoryPool& getBufferPool(){
|
||||
static oatpp::base::memory::ThreadDistributedMemoryPool pool("IOBuffer_Buffer_Pool", BUFFER_SIZE, 16);
|
||||
return pool;
|
||||
static std::once_flag flag;
|
||||
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;
|
||||
}
|
||||
private:
|
||||
void* m_entry;
|
||||
|
@ -52,8 +52,12 @@ public:
|
||||
static const v_buff_size CHUNK_CHUNK_SIZE;
|
||||
|
||||
static oatpp::base::memory::ThreadDistributedMemoryPool& getSegemntPool(){
|
||||
static oatpp::base::memory::ThreadDistributedMemoryPool pool(CHUNK_POOL_NAME, CHUNK_ENTRY_SIZE, CHUNK_CHUNK_SIZE);
|
||||
return pool;
|
||||
static std::once_flag flag;
|
||||
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;
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user