aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordanilalexeev <danilalexeev@yandex-team.com>2023-08-18 00:20:52 +0300
committerdanilalexeev <danilalexeev@yandex-team.com>2023-08-18 01:28:02 +0300
commit09ac62184db89f0ed7dc91f5da0e86e3d2b248f1 (patch)
tree31cc4f02b581f5e35b3d040ee5ba707a717fefa6
parent250dfce28a781a72fc72eec30469d50f1c33e0b6 (diff)
downloadydb-09ac62184db89f0ed7dc91f5da0e86e3d2b248f1.tar.gz
PoolAllocator::New only for derived from TObjectBase
-rw-r--r--yt/yt/core/misc/pool_allocator-inl.h2
-rw-r--r--yt/yt/core/misc/pool_allocator.h20
2 files changed, 11 insertions, 11 deletions
diff --git a/yt/yt/core/misc/pool_allocator-inl.h b/yt/yt/core/misc/pool_allocator-inl.h
index b2be895ea2..5602258bc6 100644
--- a/yt/yt/core/misc/pool_allocator-inl.h
+++ b/yt/yt/core/misc/pool_allocator-inl.h
@@ -64,7 +64,7 @@ inline void TPoolAllocator::Free(void* ptr) noexcept
header->Pool->DoFree(ptr);
}
-template <class T, class... TArgs>
+template <std::derived_from<TPoolAllocator::TObjectBase> T, class... TArgs>
std::unique_ptr<T> TPoolAllocator::New(TArgs&&... args)
{
struct TChunkTag
diff --git a/yt/yt/core/misc/pool_allocator.h b/yt/yt/core/misc/pool_allocator.h
index 16837572d8..5a53b6789f 100644
--- a/yt/yt/core/misc/pool_allocator.h
+++ b/yt/yt/core/misc/pool_allocator.h
@@ -42,16 +42,6 @@ public:
*/
static void Free(void* ptr) noexcept;
- //! Allocates a new object of type #T (typically derived from #TPoolAllocator::TObjectBase)
- //! from a per-thread pool.
- /*!
- * \note
- * The object's disposal via |operator delete| must take place within
- * the same thread the object was created.
- */
- template <class T, class... TArgs>
- static std::unique_ptr<T> New(TArgs&&... args);
-
//! A base for objects instantiated via #TPoolAllocator::New.
class TObjectBase
{
@@ -68,6 +58,16 @@ public:
void operator delete[](void* ptr) noexcept;
};
+ //! Allocates a new object of type #T (derived from #TPoolAllocator::TObjectBase)
+ //! from a per-thread pool.
+ /*!
+ * \note
+ * The object's disposal via |operator delete| must take place within
+ * the same thread the object was created.
+ */
+ template <std::derived_from<TObjectBase> T, class... TArgs>
+ static std::unique_ptr<T> New(TArgs&&... args);
+
private:
const size_t BlockSize_;
const size_t BlockAlignment_;