[Bf-blender-cvs] [9677fbe0292] functions: rename MonotonicAllocator to LinearAllocator

Jacques Lucke noreply at git.blender.org
Mon Feb 10 12:26:30 CET 2020


Commit: 9677fbe029283377e04b6168f0e3186802039e62
Author: Jacques Lucke
Date:   Mon Feb 10 10:51:18 2020 +0100
Branches: functions
https://developer.blender.org/rB9677fbe029283377e04b6168f0e3186802039e62

rename MonotonicAllocator to LinearAllocator

===================================================================

M	source/blender/blenkernel/BKE_virtual_node_tree.h
R094	source/blender/blenlib/BLI_monotonic_allocator.h	source/blender/blenlib/BLI_linear_allocator.h
M	source/blender/blenlib/BLI_multi_map.h
M	source/blender/blenlib/BLI_resource_collector.h
M	source/blender/blenlib/CMakeLists.txt
M	source/blender/functions/FN_attributes_ref.h
M	source/blender/functions/FN_generic_vector_array.h
M	source/blender/functions/FN_multi_function_network.h
M	source/blender/functions/FN_node_tree.h
M	source/blender/functions/intern/multi_functions/network.cc
R094	tests/gtests/blenlib/BLI_monotonic_allocator_test.cc	tests/gtests/blenlib/BLI_linear_allocator_test.cc
M	tests/gtests/blenlib/CMakeLists.txt

===================================================================

diff --git a/source/blender/blenkernel/BKE_virtual_node_tree.h b/source/blender/blenkernel/BKE_virtual_node_tree.h
index 51c826b963b..d253e149cb8 100644
--- a/source/blender/blenkernel/BKE_virtual_node_tree.h
+++ b/source/blender/blenkernel/BKE_virtual_node_tree.h
@@ -121,7 +121,7 @@ class VNode : BLI::NonCopyable, BLI::NonMovable {
 
 class VirtualNodeTree : BLI::NonCopyable, BLI::NonMovable {
  private:
-  BLI::MonotonicAllocator<> m_allocator;
+  BLI::LinearAllocator<> m_allocator;
   bNodeTree *m_btree;
   Vector<VNode *> m_nodes_by_id;
   Vector<VSocket *> m_sockets_by_id;
diff --git a/source/blender/blenlib/BLI_monotonic_allocator.h b/source/blender/blenlib/BLI_linear_allocator.h
similarity index 94%
rename from source/blender/blenlib/BLI_monotonic_allocator.h
rename to source/blender/blenlib/BLI_linear_allocator.h
index 838342678ec..60d19591855 100644
--- a/source/blender/blenlib/BLI_monotonic_allocator.h
+++ b/source/blender/blenlib/BLI_linear_allocator.h
@@ -17,7 +17,7 @@
 /** \file
  * \ingroup bli
  *
- * A monotonic allocator is the simplest form of an allocator. It never reuses any memory, and
+ * A linear allocator is the simplest form of an allocator. It never reuses any memory, and
  * therefore does not need a deallocation method. It simply hands out consecutive buffers of
  * memory. When the current buffer is full, it reallocates a new larger buffer and continues.
  */
@@ -32,7 +32,7 @@
 namespace BLI {
 
 template<uint N = 0, typename Allocator = GuardedAllocator>
-class MonotonicAllocator : NonCopyable, NonMovable {
+class LinearAllocator : NonCopyable, NonMovable {
  private:
   Allocator m_allocator;
   Vector<void *> m_pointers;
@@ -48,12 +48,12 @@ class MonotonicAllocator : NonCopyable, NonMovable {
 #endif
 
  public:
-  MonotonicAllocator() : m_remaining_capacity(N), m_next_min_alloc_size(std::max<uint>(N * 2, 16))
+  LinearAllocator() : m_remaining_capacity(N), m_next_min_alloc_size(std::max<uint>(N * 2, 16))
   {
     m_current_buffer = m_inline_buffer.ptr();
   }
 
-  ~MonotonicAllocator()
+  ~LinearAllocator()
   {
     for (void *ptr : m_pointers) {
       m_allocator.deallocate(ptr);
diff --git a/source/blender/blenlib/BLI_multi_map.h b/source/blender/blenlib/BLI_multi_map.h
index dcd1665519e..bb98da6d3d4 100644
--- a/source/blender/blenlib/BLI_multi_map.h
+++ b/source/blender/blenlib/BLI_multi_map.h
@@ -25,7 +25,7 @@
 #include "BLI_map.h"
 #include "BLI_array_ref.h"
 #include "BLI_vector.h"
-#include "BLI_monotonic_allocator.h"
+#include "BLI_linear_allocator.h"
 
 namespace BLI {
 
@@ -37,7 +37,7 @@ template<typename KeyT, typename ValueT, uint N = 4> class MultiMap {
     uint capacity = 0;
   };
 
-  MonotonicAllocator<sizeof(ValueT) * N> m_allocator;
+  LinearAllocator<sizeof(ValueT) * N> m_allocator;
   Map<KeyT, Entry> m_map;
 
  public:
diff --git a/source/blender/blenlib/BLI_resource_collector.h b/source/blender/blenlib/BLI_resource_collector.h
index b2e3bd3d225..aaae164bb4b 100644
--- a/source/blender/blenlib/BLI_resource_collector.h
+++ b/source/blender/blenlib/BLI_resource_collector.h
@@ -4,7 +4,7 @@
 #include "BLI_vector.h"
 #include "BLI_utility_mixins.h"
 #include "BLI_string_ref.h"
-#include "BLI_monotonic_allocator.h"
+#include "BLI_linear_allocator.h"
 
 namespace BLI {
 
@@ -16,7 +16,7 @@ class ResourceCollector : NonCopyable {
     const char *name;
   };
 
-  MonotonicAllocator<> m_allocator;
+  LinearAllocator<> m_allocator;
   Vector<ResourceData> m_resources;
 
  public:
@@ -64,7 +64,7 @@ class ResourceCollector : NonCopyable {
     return m_allocator.allocate(size, alignment);
   }
 
-  MonotonicAllocator<> &allocator()
+  LinearAllocator<> &allocator()
   {
     return m_allocator;
   }
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index 83b86d265ea..ec4a2f0e8c8 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -262,7 +262,7 @@ set(SRC
   BLI_lazy_init_cxx.h
   intern/BLI_lazy_init.cc
   BLI_math_cxx.h
-  BLI_monotonic_allocator.h
+  BLI_linear_allocator.h
   BLI_optional.h
   BLI_refcount.h
   BLI_multi_map.h
diff --git a/source/blender/functions/FN_attributes_ref.h b/source/blender/functions/FN_attributes_ref.h
index 3ad29896cc4..6c9d992798f 100644
--- a/source/blender/functions/FN_attributes_ref.h
+++ b/source/blender/functions/FN_attributes_ref.h
@@ -9,14 +9,14 @@
 #include "BLI_vector_set.h"
 #include "BLI_string_map.h"
 #include "BLI_optional.h"
-#include "BLI_monotonic_allocator.h"
+#include "BLI_linear_allocator.h"
 
 namespace FN {
 
 using BLI::Array;
 using BLI::ArrayRef;
 using BLI::IndexRange;
-using BLI::MonotonicAllocator;
+using BLI::LinearAllocator;
 using BLI::MutableArrayRef;
 using BLI::Optional;
 using BLI::StringMap;
@@ -27,7 +27,7 @@ class AttributesInfo;
 
 class AttributesInfoBuilder : BLI::NonCopyable, BLI::NonMovable {
  private:
-  MonotonicAllocator<32> m_allocator;
+  LinearAllocator<32> m_allocator;
   VectorSet<std::string> m_names;
   Vector<const CPPType *> m_types;
   Vector<void *> m_defaults;
@@ -100,7 +100,7 @@ class AttributesInfoBuilder : BLI::NonCopyable, BLI::NonMovable {
 
 class AttributesInfo : BLI::NonCopyable, BLI::NonMovable {
  private:
-  MonotonicAllocator<32> m_allocator;
+  LinearAllocator<32> m_allocator;
   StringMap<int> m_index_by_name;
   Vector<std::string> m_name_by_index;
   Vector<const CPPType *> m_type_by_index;
diff --git a/source/blender/functions/FN_generic_vector_array.h b/source/blender/functions/FN_generic_vector_array.h
index cd8d5de6dea..8661321b4e6 100644
--- a/source/blender/functions/FN_generic_vector_array.h
+++ b/source/blender/functions/FN_generic_vector_array.h
@@ -7,19 +7,19 @@
 
 #include "BLI_array_ref.h"
 #include "BLI_index_range.h"
-#include "BLI_monotonic_allocator.h"
+#include "BLI_linear_allocator.h"
 
 namespace FN {
 
 using BLI::ArrayRef;
 using BLI::IndexRange;
-using BLI::MonotonicAllocator;
+using BLI::LinearAllocator;
 using BLI::MutableArrayRef;
 
 class GenericVectorArray : BLI::NonCopyable, BLI::NonMovable {
  private:
   BLI::GuardedAllocator m_slices_allocator;
-  MonotonicAllocator<> m_elements_allocator;
+  LinearAllocator<> m_elements_allocator;
   const CPPType &m_type;
   void **m_starts;
   uint *m_lengths;
diff --git a/source/blender/functions/FN_multi_function_network.h b/source/blender/functions/FN_multi_function_network.h
index 01890e5493b..5015cecb9cc 100644
--- a/source/blender/functions/FN_multi_function_network.h
+++ b/source/blender/functions/FN_multi_function_network.h
@@ -137,7 +137,7 @@ class MFBuilderOutputSocket : public MFBuilderSocket {
 
 class MFNetworkBuilder : BLI::NonCopyable, BLI::NonMovable {
  private:
-  MonotonicAllocator<> m_allocator;
+  LinearAllocator<> m_allocator;
 
   VectorSet<MFBuilderFunctionNode *> m_function_nodes;
   VectorSet<MFBuilderDummyNode *> m_dummy_nodes;
@@ -373,7 +373,7 @@ class MFOutputSocket final : public MFSocket {
 
 class MFNetwork : BLI::NonCopyable, BLI::NonMovable {
  private:
-  MonotonicAllocator<> m_allocator;
+  LinearAllocator<> m_allocator;
 
   Vector<MFNode *> m_node_by_id;
   Vector<MFSocket *> m_socket_by_id;
diff --git a/source/blender/functions/FN_node_tree.h b/source/blender/functions/FN_node_tree.h
index 12c3087c6b5..8161c6df95a 100644
--- a/source/blender/functions/FN_node_tree.h
+++ b/source/blender/functions/FN_node_tree.h
@@ -155,7 +155,7 @@ using BTreeVTreeMap = Map<bNodeTree *, std::unique_ptr<const VirtualNodeTree>>;
 
 class FunctionTree : BLI::NonCopyable, BLI::NonMovable {
  private:
-  BLI::MonotonicAllocator<> m_allocator;
+  BLI::LinearAllocator<> m_allocator;
   bNodeTree *m_btree;
   Vector<FNode *> m_node_by_id;
   Vector<FGroupInput *> m_group_inputs;
diff --git a/source/blender/functions/intern/multi_functions/network.cc b/source/blender/functions/intern/multi_functions/network.cc
index 500aa63e2a4..39f3e5786dd 100644
--- a/source/blender/functions/intern/multi_functions/network.cc
+++ b/source/blender/functions/intern/multi_functions/network.cc
@@ -104,7 +104,7 @@ struct OwnVectorValue : public Value {
 
 class NetworkEvaluationStorage {
  private:
-  MonotonicAllocator<256> m_allocator;
+  LinearAllocator<256> m_allocator;
   BufferCache &m_buffer_cache;
   IndexMask m_mask;
   Array<Value *> m_value_per_output_id;
diff --git a/tests/gtests/blenlib/BLI_monotonic_allocator_test.cc b/tests/gtests/blenlib/BLI_linear_allocator_test.cc
similarity index 94%
rename from tests/gtests/blenlib/BLI_monotonic_allocator_test.cc
rename to tests/gtests/blenlib/BLI_linear_allocator_test.cc
index 82261027c1a..6d80a0957ce 100644
--- a/tests/gtests/blenlib/BLI_monotonic_allocator_test.cc
+++ b/tests/gtests/blenlib/BLI_linear_allocator_test.cc
@@ -1,5 +1,5 @@
 #include "testing/testing.h"
-#include "BLI_monotonic_allocator.h"
+#include "BLI_linear_allocator.h"
 
 using namespace BLI;
 
@@ -11,7 +11,7 @@ static bool is_aligned(void *ptr, uint alignment)
 
 TEST(monotonic_allocator, AllocationAlignment)
 {
-  MonotonicAllocator<> allocator;
+  LinearAllocator<> allocator;
 
   EXPECT_TRUE(is_aligned(allocator.allocate(10, 4), 4));
   EXPECT_TRUE(is_aligned(allocator.allocate(10, 4), 4));
@@ -28,7 +28,7 @@ TEST(monotonic_allocator, AllocationAlignment)
 
 TEST(monotonic_allocator, PackedAllocation)
 {
-  MonotonicAllocator<256> allocator;
+  LinearAllocator<256> allocator;
   allocator.allocate(32, 32);
 
   uintptr_t ptr1 = (uintptr_t)allocator.allocate(10, 4); /*  0 - 10 */
diff --git a/tests/gtests/blenlib/CMakeLists.txt b/tests/gtests/blenlib/CMakeLists.txt
index 9f15732ba75..8f7f9d64a1f 100644
--- a/tests/gtests/blenlib/CMakeLists.txt
+++ b/tests/gtests/blenlib/CMakeLists.txt
@@ -62,7 +62,7 @@ BLENDER_TEST(BLI_math_base "bf_blenlib")
 BLENDER_TEST(BLI_math_color "bf_blenlib")
 BLENDER_TEST(BLI_math_geom "bf_blenlib")
 BLENDER_TEST(BLI_memiter "bf_blenlib")
-BLENDER_TEST(BLI_monotonic_allocator "bf_blenlib")
+BLENDER_TEST(BLI_linear_allocator "bf_blenlib")
 BLENDER_TEST(BLI_multi_map "bf_blenlib")
 BLENDER_TEST(BLI_multi_vector "bf_blenlib")
 BLENDER_TEST(BLI_optional "bf_blenlib")



More information about the Bf-blender-cvs mailing list