From 2d5a5e1f1a611ef2d558d1dfbbe96dfd62c719c0 Mon Sep 17 00:00:00 2001 From: nolan-veed <88709630+nolan-veed@users.noreply.github.com> Date: Mon, 13 Nov 2023 08:41:10 +0000 Subject: [PATCH] Renamed Pool. --- src/internal_modules/roc_core/buffer.h | 2 +- .../roc_core/buffer_factory.h | 4 +- .../roc_core/{pool.h => slab_pool.h} | 32 ++-- .../{pool_impl.cpp => slab_pool_impl.cpp} | 54 +++--- .../{pool_impl.h => slab_pool_impl.h} | 32 ++-- src/internal_modules/roc_node/receiver.h | 4 +- src/internal_modules/roc_node/sender.h | 4 +- src/internal_modules/roc_packet/packet.h | 2 +- .../roc_packet/packet_factory.h | 4 +- src/internal_modules/roc_rtp/format_map.h | 4 +- .../{test_pool.cpp => test_slab_pool.cpp} | 154 +++++++++--------- 11 files changed, 148 insertions(+), 148 deletions(-) rename src/internal_modules/roc_core/{pool.h => slab_pool.h} (83%) rename src/internal_modules/roc_core/{pool_impl.cpp => slab_pool_impl.cpp} (84%) rename src/internal_modules/roc_core/{pool_impl.h => slab_pool_impl.h} (84%) rename src/tests/roc_core/{test_pool.cpp => test_slab_pool.cpp} (70%) diff --git a/src/internal_modules/roc_core/buffer.h b/src/internal_modules/roc_core/buffer.h index caa52c0f9a..c2f11044fa 100644 --- a/src/internal_modules/roc_core/buffer.h +++ b/src/internal_modules/roc_core/buffer.h @@ -14,8 +14,8 @@ #include "roc_core/align_ops.h" #include "roc_core/macro_helpers.h" -#include "roc_core/pool.h" #include "roc_core/ref_counted.h" +#include "roc_core/slab_pool.h" #include "roc_core/stddefs.h" namespace roc { diff --git a/src/internal_modules/roc_core/buffer_factory.h b/src/internal_modules/roc_core/buffer_factory.h index 162180e46b..ee50bc9739 100644 --- a/src/internal_modules/roc_core/buffer_factory.h +++ b/src/internal_modules/roc_core/buffer_factory.h @@ -15,8 +15,8 @@ #include "roc_core/allocation_policy.h" #include "roc_core/buffer.h" #include "roc_core/noncopyable.h" -#include "roc_core/pool.h" #include "roc_core/shared_ptr.h" +#include "roc_core/slab_pool.h" namespace roc { namespace core { @@ -44,7 +44,7 @@ template class BufferFactory : public core::NonCopyable<> { } private: - Pool > buffer_pool_; + SlabPool > buffer_pool_; const size_t buffer_size_; }; diff --git a/src/internal_modules/roc_core/pool.h b/src/internal_modules/roc_core/slab_pool.h similarity index 83% rename from src/internal_modules/roc_core/pool.h rename to src/internal_modules/roc_core/slab_pool.h index c119426253..df1f37024b 100644 --- a/src/internal_modules/roc_core/pool.h +++ b/src/internal_modules/roc_core/slab_pool.h @@ -6,18 +6,18 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -//! @file roc_core/pool.h +//! @file roc_core/slab_pool.h //! @brief Memory pool. -#ifndef ROC_CORE_POOL_H_ -#define ROC_CORE_POOL_H_ +#ifndef ROC_CORE_SLAB_POOL_H_ +#define ROC_CORE_SLAB_POOL_H_ #include "roc_core/aligned_storage.h" #include "roc_core/attributes.h" #include "roc_core/iarena.h" #include "roc_core/ipool.h" #include "roc_core/noncopyable.h" -#include "roc_core/pool_impl.h" +#include "roc_core/slab_pool_impl.h" #include "roc_core/stddefs.h" namespace roc { @@ -56,13 +56,13 @@ enum { DefaultPoolFlags = (PoolFlag_EnableGuards) }; //! @tparam T defines pool object type. It is used to determine allocation size. If //! runtime size is different from static size of T, it can be provided via constructor. //! -//! @tparam EmbeddedCapacity defines number of slots embedded directly into Pool +//! @tparam EmbeddedCapacity defines number of slots embedded directly into SlabPool //! instance. If non-zero, this memory will be used for first allocations, before //! using memory arena. //! //! Thread-safe. template -class Pool : public IPool, public NonCopyable<> { +class SlabPool : public IPool, public NonCopyable<> { public: //! Initialize. //! @@ -73,12 +73,12 @@ class Pool : public IPool, public NonCopyable<> { //! - @p min_alloc_bytes defines minimum size in bytes per request to arena //! - @p max_alloc_bytes defines maximum size in bytes per request to arena //! - @p flags defines options to modify behaviour as indicated in PoolFlags - explicit Pool(const char* name, - IArena& arena, - size_t object_size = sizeof(T), - size_t min_alloc_bytes = 0, - size_t max_alloc_bytes = 0, - size_t flags = DefaultPoolFlags) + explicit SlabPool(const char* name, + IArena& arena, + size_t object_size = sizeof(T), + size_t min_alloc_bytes = 0, + size_t max_alloc_bytes = 0, + size_t flags = DefaultPoolFlags) : impl_(name, arena, object_size, @@ -116,15 +116,15 @@ class Pool : public IPool, public NonCopyable<> { private: enum { - SlotSize = (sizeof(PoolImpl::SlotHeader) + sizeof(PoolImpl::SlotCanary) - + sizeof(T) + sizeof(PoolImpl::SlotCanary) + sizeof(AlignMax) - 1) + SlotSize = (sizeof(SlabPoolImpl::SlotHeader) + sizeof(SlabPoolImpl::SlotCanary) + + sizeof(T) + sizeof(SlabPoolImpl::SlotCanary) + sizeof(AlignMax) - 1) / sizeof(AlignMax) * sizeof(AlignMax) }; AlignedStorage embedded_data_; - PoolImpl impl_; + SlabPoolImpl impl_; }; } // namespace core } // namespace roc -#endif // ROC_CORE_POOL_H_ +#endif // ROC_CORE_SLAB_POOL_H_ diff --git a/src/internal_modules/roc_core/pool_impl.cpp b/src/internal_modules/roc_core/slab_pool_impl.cpp similarity index 84% rename from src/internal_modules/roc_core/pool_impl.cpp rename to src/internal_modules/roc_core/slab_pool_impl.cpp index dedd576226..9b63fa479e 100644 --- a/src/internal_modules/roc_core/pool_impl.cpp +++ b/src/internal_modules/roc_core/slab_pool_impl.cpp @@ -6,12 +6,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "roc_core/pool_impl.h" +#include "roc_core/slab_pool_impl.h" #include "roc_core/align_ops.h" #include "roc_core/log.h" #include "roc_core/memory_ops.h" #include "roc_core/panic.h" -#include "roc_core/pool.h" +#include "roc_core/slab_pool.h" namespace roc { namespace core { @@ -30,14 +30,14 @@ size_t clamp(size_t value, size_t lower_limit, size_t upper_limit) { } // namespace -PoolImpl::PoolImpl(const char* name, - IArena& arena, - size_t object_size, - size_t min_alloc_bytes, - size_t max_alloc_bytes, - void* preallocated_data, - size_t preallocated_size, - size_t flags) +SlabPoolImpl::SlabPoolImpl(const char* name, + IArena& arena, + size_t object_size, + size_t min_alloc_bytes, + size_t max_alloc_bytes, + void* preallocated_data, + size_t preallocated_size, + size_t flags) : name_(name) , arena_(arena) , n_used_slots_(0) @@ -68,21 +68,21 @@ PoolImpl::PoolImpl(const char* name, } } -PoolImpl::~PoolImpl() { +SlabPoolImpl::~SlabPoolImpl() { deallocate_everything_(); } -size_t PoolImpl::object_size() const { +size_t SlabPoolImpl::object_size() const { return object_size_; } -bool PoolImpl::reserve(size_t n_objects) { +bool SlabPoolImpl::reserve(size_t n_objects) { Mutex::Lock lock(mutex_); return reserve_slots_(n_objects); } -void* PoolImpl::allocate() { +void* SlabPoolImpl::allocate() { Slot* slot; { @@ -98,7 +98,7 @@ void* PoolImpl::allocate() { return give_slot_to_user_(slot); } -void PoolImpl::deallocate(void* memory) { +void SlabPoolImpl::deallocate(void* memory) { if (memory == NULL) { roc_panic("pool: deallocating null pointer: name=%s", name_); } @@ -116,13 +116,13 @@ void PoolImpl::deallocate(void* memory) { } } -size_t PoolImpl::num_guard_failures() const { +size_t SlabPoolImpl::num_guard_failures() const { Mutex::Lock lock(mutex_); return num_guard_failures_; } -void* PoolImpl::give_slot_to_user_(Slot* slot) { +void* SlabPoolImpl::give_slot_to_user_(Slot* slot) { slot->~Slot(); SlotHeader* slot_hdr = (SlotHeader*)slot; @@ -140,7 +140,7 @@ void* PoolImpl::give_slot_to_user_(Slot* slot) { return memory; } -PoolImpl::Slot* PoolImpl::take_slot_from_user_(void* memory) { +SlabPoolImpl::Slot* SlabPoolImpl::take_slot_from_user_(void* memory) { SlotHeader* slot_hdr = ROC_CONTAINER_OF((char*)memory - sizeof(SlotCanary), SlotHeader, data); @@ -177,7 +177,7 @@ PoolImpl::Slot* PoolImpl::take_slot_from_user_(void* memory) { return new (slot_hdr) Slot; } -PoolImpl::Slot* PoolImpl::acquire_slot_() { +SlabPoolImpl::Slot* SlabPoolImpl::acquire_slot_() { if (free_slots_.is_empty()) { allocate_new_slab_(); } @@ -191,7 +191,7 @@ PoolImpl::Slot* PoolImpl::acquire_slot_() { return slot; } -void PoolImpl::release_slot_(Slot* slot) { +void SlabPoolImpl::release_slot_(Slot* slot) { if (n_used_slots_ == 0) { roc_panic("pool: unpaired deallocation: name=%s", name_); } @@ -200,7 +200,7 @@ void PoolImpl::release_slot_(Slot* slot) { free_slots_.push_front(*slot); } -bool PoolImpl::reserve_slots_(size_t desired_slots) { +bool SlabPoolImpl::reserve_slots_(size_t desired_slots) { if (desired_slots > free_slots_.size()) { increase_slab_size_(desired_slots - free_slots_.size()); @@ -214,7 +214,7 @@ bool PoolImpl::reserve_slots_(size_t desired_slots) { return true; } -void PoolImpl::increase_slab_size_(size_t desired_slots) { +void SlabPoolImpl::increase_slab_size_(size_t desired_slots) { if (desired_slots > slab_max_slots_ && slab_max_slots_ != 0) { desired_slots = slab_max_slots_; } @@ -229,7 +229,7 @@ void PoolImpl::increase_slab_size_(size_t desired_slots) { } } -bool PoolImpl::allocate_new_slab_() { +bool SlabPoolImpl::allocate_new_slab_() { const size_t slab_size_bytes = slot_offset_(slab_cur_slots_); void* memory = arena_.allocate(slab_size_bytes); @@ -249,7 +249,7 @@ bool PoolImpl::allocate_new_slab_() { return true; } -void PoolImpl::deallocate_everything_() { +void SlabPoolImpl::deallocate_everything_() { if (n_used_slots_ != 0) { roc_panic("pool: detected memory leak: name=%s n_used=%lu n_free=%lu", name_, (unsigned long)n_used_slots_, (unsigned long)free_slots_.size()); @@ -265,7 +265,7 @@ void PoolImpl::deallocate_everything_() { } } -void PoolImpl::add_preallocated_memory_(void* memory, size_t memory_size) { +void SlabPoolImpl::add_preallocated_memory_(void* memory, size_t memory_size) { if (memory == NULL) { roc_panic("pool: preallocated memory is null: name=%s", name_); } @@ -278,7 +278,7 @@ void PoolImpl::add_preallocated_memory_(void* memory, size_t memory_size) { } } -size_t PoolImpl::slots_per_slab_(size_t slab_size, bool round_up) const { +size_t SlabPoolImpl::slots_per_slab_(size_t slab_size, bool round_up) const { roc_panic_if(slot_size_ == 0); if (slab_size < slab_hdr_size_) { @@ -293,7 +293,7 @@ size_t PoolImpl::slots_per_slab_(size_t slab_size, bool round_up) const { / slot_size_; } -size_t PoolImpl::slot_offset_(size_t slot_index) const { +size_t SlabPoolImpl::slot_offset_(size_t slot_index) const { return slab_hdr_size_ + slot_index * slot_size_; } diff --git a/src/internal_modules/roc_core/pool_impl.h b/src/internal_modules/roc_core/slab_pool_impl.h similarity index 84% rename from src/internal_modules/roc_core/pool_impl.h rename to src/internal_modules/roc_core/slab_pool_impl.h index cad218a43f..5d2950abbc 100644 --- a/src/internal_modules/roc_core/pool_impl.h +++ b/src/internal_modules/roc_core/slab_pool_impl.h @@ -6,11 +6,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -//! @file roc_core/pool_impl.h +//! @file roc_core/slab_pool_impl.h //! @brief Memory pool implementation class. -#ifndef ROC_CORE_POOL_IMPL_H_ -#define ROC_CORE_POOL_IMPL_H_ +#ifndef ROC_CORE_SLAB_POOL_IMPL_H_ +#define ROC_CORE_SLAB_POOL_IMPL_H_ #include "roc_core/align_ops.h" #include "roc_core/attributes.h" @@ -42,13 +42,13 @@ namespace core { //! If user data requires padding to be maximum-aligned, this padding //! also becomes part of the trailing canary guard. //! -//! @see Pool. -class PoolImpl : public NonCopyable<> { +//! @see SlabPool. +class SlabPoolImpl : public NonCopyable<> { public: //! Slot header. struct SlotHeader { //! The pool that the slot belongs to. - PoolImpl* owner; + SlabPoolImpl* owner; //! Variable-length data surrounded by canary guard. AlignMax data[]; }; @@ -57,17 +57,17 @@ class PoolImpl : public NonCopyable<> { typedef AlignMax SlotCanary; //! Initialize. - PoolImpl(const char* name, - IArena& arena, - size_t object_size, - size_t min_alloc_bytes, - size_t max_alloc_bytes, - void* preallocated_data, - size_t preallocated_size, - size_t flags); + SlabPoolImpl(const char* name, + IArena& arena, + size_t object_size, + size_t min_alloc_bytes, + size_t max_alloc_bytes, + void* preallocated_data, + size_t preallocated_size, + size_t flags); //! Deinitialize. - ~PoolImpl(); + ~SlabPoolImpl(); //! Get size of objects in pool. size_t object_size() const; @@ -133,4 +133,4 @@ class PoolImpl : public NonCopyable<> { } // namespace core } // namespace roc -#endif // ROC_CORE_POOL_IMPL_H_ +#endif // ROC_CORE_SLAB_POOL_IMPL_H_ diff --git a/src/internal_modules/roc_node/receiver.h b/src/internal_modules/roc_node/receiver.h index ed87c47cfe..21134b88f1 100644 --- a/src/internal_modules/roc_node/receiver.h +++ b/src/internal_modules/roc_node/receiver.h @@ -17,8 +17,8 @@ #include "roc_address/protocol.h" #include "roc_core/hashmap.h" #include "roc_core/mutex.h" -#include "roc_core/pool.h" #include "roc_core/ref_counted.h" +#include "roc_core/slab_pool.h" #include "roc_core/stddefs.h" #include "roc_ctl/control_loop.h" #include "roc_node/context.h" @@ -132,7 +132,7 @@ class Receiver : public Node, private pipeline::IPipelineTaskScheduler { pipeline::ReceiverLoop pipeline_; ctl::ControlLoop::Tasks::PipelineProcessing processing_task_; - core::Pool slot_pool_; + core::SlabPool slot_pool_; core::Hashmap slot_map_; bool used_interfaces_[address::Iface_Max]; diff --git a/src/internal_modules/roc_node/sender.h b/src/internal_modules/roc_node/sender.h index 36050a8dbf..8ff01d06d7 100644 --- a/src/internal_modules/roc_node/sender.h +++ b/src/internal_modules/roc_node/sender.h @@ -18,9 +18,9 @@ #include "roc_core/allocation_policy.h" #include "roc_core/hashmap.h" #include "roc_core/mutex.h" -#include "roc_core/pool.h" #include "roc_core/ref_counted.h" #include "roc_core/scoped_ptr.h" +#include "roc_core/slab_pool.h" #include "roc_core/stddefs.h" #include "roc_node/context.h" #include "roc_node/node.h" @@ -138,7 +138,7 @@ class Sender : public Node, private pipeline::IPipelineTaskScheduler { pipeline::SenderLoop pipeline_; ctl::ControlLoop::Tasks::PipelineProcessing processing_task_; - core::Pool slot_pool_; + core::SlabPool slot_pool_; core::Hashmap slot_map_; bool used_interfaces_[address::Iface_Max]; diff --git a/src/internal_modules/roc_packet/packet.h b/src/internal_modules/roc_packet/packet.h index 900c8898a2..cb9a915d59 100644 --- a/src/internal_modules/roc_packet/packet.h +++ b/src/internal_modules/roc_packet/packet.h @@ -15,9 +15,9 @@ #include "roc_core/list_node.h" #include "roc_core/macro_helpers.h" #include "roc_core/mpsc_queue_node.h" -#include "roc_core/pool.h" #include "roc_core/ref_counted.h" #include "roc_core/shared_ptr.h" +#include "roc_core/slab_pool.h" #include "roc_packet/fec.h" #include "roc_packet/print_packet.h" #include "roc_packet/rtcp.h" diff --git a/src/internal_modules/roc_packet/packet_factory.h b/src/internal_modules/roc_packet/packet_factory.h index 00cc83a9e0..7c3f81bd4e 100644 --- a/src/internal_modules/roc_packet/packet_factory.h +++ b/src/internal_modules/roc_packet/packet_factory.h @@ -14,8 +14,8 @@ #include "roc_core/allocation_policy.h" #include "roc_core/noncopyable.h" -#include "roc_core/pool.h" #include "roc_core/shared_ptr.h" +#include "roc_core/slab_pool.h" #include "roc_packet/packet.h" namespace roc { @@ -31,7 +31,7 @@ class PacketFactory : public core::NonCopyable<> { core::SharedPtr new_packet(); private: - core::Pool pool_; + core::SlabPool pool_; }; } // namespace packet diff --git a/src/internal_modules/roc_rtp/format_map.h b/src/internal_modules/roc_rtp/format_map.h index 9789787235..21ab18600c 100644 --- a/src/internal_modules/roc_rtp/format_map.h +++ b/src/internal_modules/roc_rtp/format_map.h @@ -19,8 +19,8 @@ #include "roc_core/iarena.h" #include "roc_core/mutex.h" #include "roc_core/noncopyable.h" -#include "roc_core/pool.h" #include "roc_core/ref_counted.h" +#include "roc_core/slab_pool.h" #include "roc_rtp/format.h" namespace roc { @@ -81,7 +81,7 @@ class FormatMap : public core::NonCopyable<> { core::Mutex mutex_; - core::Pool node_pool_; + core::SlabPool node_pool_; core::Hashmap node_map_; }; diff --git a/src/tests/roc_core/test_pool.cpp b/src/tests/roc_core/test_slab_pool.cpp similarity index 70% rename from src/tests/roc_core/test_pool.cpp rename to src/tests/roc_core/test_slab_pool.cpp index 4893b06c2b..90c69a4816 100644 --- a/src/tests/roc_core/test_pool.cpp +++ b/src/tests/roc_core/test_slab_pool.cpp @@ -11,7 +11,7 @@ #include "roc_core/heap_arena.h" #include "roc_core/memory_ops.h" #include "roc_core/noncopyable.h" -#include "roc_core/pool.h" +#include "roc_core/slab_pool.h" namespace roc { namespace core { @@ -41,20 +41,20 @@ struct TestObject { } // namespace -TEST_GROUP(pool) {}; +TEST_GROUP(slab_pool) {}; -TEST(pool, object_size) { +TEST(slab_pool, object_size) { TestArena arena; - Pool pool("test", arena); + SlabPool pool("test", arena); LONGS_EQUAL(sizeof(TestObject), pool.object_size()); } -TEST(pool, allocate_deallocate) { +TEST(slab_pool, allocate_deallocate) { TestArena arena; { - Pool pool("test", arena); + SlabPool pool("test", arena); LONGS_EQUAL(0, arena.num_allocations()); @@ -71,11 +71,11 @@ TEST(pool, allocate_deallocate) { LONGS_EQUAL(0, arena.num_allocations()); } -TEST(pool, allocate_deallocate_many) { +TEST(slab_pool, allocate_deallocate_many) { TestArena arena; { - Pool pool("test", arena); + SlabPool pool("test", arena); for (int i = 0; i < 10; i++) { void* pointers[1 + 2 + 4] = {}; @@ -115,11 +115,11 @@ TEST(pool, allocate_deallocate_many) { LONGS_EQUAL(0, arena.num_allocations()); } -TEST(pool, reserve) { +TEST(slab_pool, reserve) { TestArena arena; { - Pool pool("test", arena); + SlabPool pool("test", arena); LONGS_EQUAL(0, arena.num_allocations()); @@ -140,11 +140,11 @@ TEST(pool, reserve) { LONGS_EQUAL(0, arena.num_allocations()); } -TEST(pool, reserve_many) { +TEST(slab_pool, reserve_many) { TestArena arena; { - Pool pool("test", arena); + SlabPool pool("test", arena); for (int i = 0; i < 10; i++) { void* pointers[1 + 2 + 4] = {}; @@ -196,14 +196,14 @@ TEST(pool, reserve_many) { LONGS_EQUAL(0, arena.num_allocations()); } -TEST(pool, min_size_allocate) { +TEST(slab_pool, min_size_allocate) { // min_size=0 { TestArena arena; - Pool pool("test", arena, - sizeof(TestObject), // object_size - 0, // min_size - 0 // max_size + SlabPool pool("test", arena, + sizeof(TestObject), // object_size + 0, // min_size + 0 // max_size ); void* mem = pool.allocate(); @@ -218,10 +218,10 @@ TEST(pool, min_size_allocate) { // min_size=sizeof(TestObject) { TestArena arena; - Pool pool("test", arena, - sizeof(TestObject), // object_size - sizeof(TestObject), // min_size - 0 // max_size + SlabPool pool("test", arena, + sizeof(TestObject), // object_size + sizeof(TestObject), // min_size + 0 // max_size ); void* mem = pool.allocate(); @@ -236,10 +236,10 @@ TEST(pool, min_size_allocate) { // min_size=sizeof(TestObject)*2 { TestArena arena; - Pool pool("test", arena, - sizeof(TestObject), // object_size - sizeof(TestObject) * 2, // min_size - 0 // max_size + SlabPool pool("test", arena, + sizeof(TestObject), // object_size + sizeof(TestObject) * 2, // min_size + 0 // max_size ); void* mem = pool.allocate(); @@ -253,14 +253,14 @@ TEST(pool, min_size_allocate) { } } -TEST(pool, min_size_reserve) { +TEST(slab_pool, min_size_reserve) { // min_size=0 { TestArena arena; - Pool pool("test", arena, - sizeof(TestObject), // object_size - 0, // min_size - 0 // max_size + SlabPool pool("test", arena, + sizeof(TestObject), // object_size + 0, // min_size + 0 // max_size ); CHECK(pool.reserve(1)); @@ -273,10 +273,10 @@ TEST(pool, min_size_reserve) { // min_size=sizeof(TestObject) { TestArena arena; - Pool pool("test", arena, - sizeof(TestObject), // object_size - sizeof(TestObject), // min_size - 0 // max_size + SlabPool pool("test", arena, + sizeof(TestObject), // object_size + sizeof(TestObject), // min_size + 0 // max_size ); CHECK(pool.reserve(1)); @@ -289,10 +289,10 @@ TEST(pool, min_size_reserve) { // min_size=sizeof(TestObject)*2 { TestArena arena; - Pool pool("test", arena, - sizeof(TestObject), // object_size - sizeof(TestObject) * 2, // min_size - 0 // max_size + SlabPool pool("test", arena, + sizeof(TestObject), // object_size + sizeof(TestObject) * 2, // min_size + 0 // max_size ); CHECK(pool.reserve(1)); @@ -304,14 +304,14 @@ TEST(pool, min_size_reserve) { } } -TEST(pool, max_size_allocate) { +TEST(slab_pool, max_size_allocate) { // max_size=0 { TestArena arena; - Pool pool("test", arena, - sizeof(TestObject), // object_size - 0, // min_size - 0 // max_size + SlabPool pool("test", arena, + sizeof(TestObject), // object_size + 0, // min_size + 0 // max_size ); { @@ -332,10 +332,10 @@ TEST(pool, max_size_allocate) { // max_size=sizeof(TestObject)*100 { TestArena arena; - Pool pool("test", arena, - sizeof(TestObject), // object_size - 0, // min_size - sizeof(TestObject) * 100 // max_size + SlabPool pool("test", arena, + sizeof(TestObject), // object_size + 0, // min_size + sizeof(TestObject) * 100 // max_size ); { @@ -356,10 +356,10 @@ TEST(pool, max_size_allocate) { // max_size=sizeof(TestObject)*2 { TestArena arena; - Pool pool("test", arena, - sizeof(TestObject), // object_size - 0, // min_size - sizeof(TestObject) * 2 // max_size + SlabPool pool("test", arena, + sizeof(TestObject), // object_size + 0, // min_size + sizeof(TestObject) * 2 // max_size ); { @@ -379,14 +379,14 @@ TEST(pool, max_size_allocate) { } } -TEST(pool, max_size_reserve) { +TEST(slab_pool, max_size_reserve) { // max_size=0 { TestArena arena; - Pool pool("test", arena, - sizeof(TestObject), // object_size - 0, // min_size - 0 // max_size + SlabPool pool("test", arena, + sizeof(TestObject), // object_size + 0, // min_size + 0 // max_size ); CHECK(pool.reserve(10)); @@ -396,10 +396,10 @@ TEST(pool, max_size_reserve) { // max_size=sizeof(TestObject)*100 { TestArena arena; - Pool pool("test", arena, - sizeof(TestObject), // object_size - 0, // min_size - sizeof(TestObject) * 100 // max_size + SlabPool pool("test", arena, + sizeof(TestObject), // object_size + 0, // min_size + sizeof(TestObject) * 100 // max_size ); CHECK(pool.reserve(10)); @@ -409,10 +409,10 @@ TEST(pool, max_size_reserve) { // max_size=sizeof(TestObject)*2 { TestArena arena; - Pool pool("test", arena, - sizeof(TestObject), // object_size - 0, // min_size - sizeof(TestObject) * 2 // max_size + SlabPool pool("test", arena, + sizeof(TestObject), // object_size + 0, // min_size + sizeof(TestObject) * 2 // max_size ); CHECK(pool.reserve(10)); @@ -421,11 +421,11 @@ TEST(pool, max_size_reserve) { } } -TEST(pool, embedded_capacity) { +TEST(slab_pool, embedded_capacity) { TestArena arena; { - Pool pool("test", arena); + SlabPool pool("test", arena); LONGS_EQUAL(0, arena.num_allocations()); @@ -453,11 +453,11 @@ TEST(pool, embedded_capacity) { LONGS_EQUAL(0, arena.num_allocations()); } -TEST(pool, embedded_capacity_reuse) { +TEST(slab_pool, embedded_capacity_reuse) { TestArena arena; { - Pool pool("test", arena); + SlabPool pool("test", arena); for (int i = 0; i < 10; i++) { LONGS_EQUAL(0, arena.num_allocations()); @@ -480,9 +480,9 @@ TEST(pool, embedded_capacity_reuse) { LONGS_EQUAL(0, arena.num_allocations()); } -TEST(pool, guard_object) { +TEST(slab_pool, guard_object) { TestArena arena; - Pool pool("test", arena); + SlabPool pool("test", arena); void* pointer = NULL; pointer = pool.allocate(); @@ -497,10 +497,10 @@ TEST(pool, guard_object) { pool.deallocate(pointer); } -TEST(pool, guard_object_violations) { +TEST(slab_pool, guard_object_violations) { TestArena arena; - Pool pool("test", arena, sizeof(TestObject), 0, 0, - (DefaultPoolFlags & ~PoolFlag_EnableGuards)); + SlabPool pool("test", arena, sizeof(TestObject), 0, 0, + (DefaultPoolFlags & ~PoolFlag_EnableGuards)); void* pointers[2] = {}; pointers[0] = pool.allocate(); @@ -526,11 +526,11 @@ TEST(pool, guard_object_violations) { CHECK(pool.num_guard_failures() == 2); } -TEST(pool, object_ownership_guard) { +TEST(slab_pool, object_ownership_guard) { TestArena arena; - Pool pool0("test", arena, sizeof(TestObject), 0, 0, - (DefaultPoolFlags & ~PoolFlag_EnableGuards)); - Pool pool1("test", arena); + SlabPool pool0("test", arena, sizeof(TestObject), 0, 0, + (DefaultPoolFlags & ~PoolFlag_EnableGuards)); + SlabPool pool1("test", arena); void* pointers[2] = {};