[Bf-blender-cvs] [80a994776bd] functions: use multi mempool for source information
Jacques Lucke
noreply at git.blender.org
Tue Mar 26 17:34:54 CET 2019
Commit: 80a994776bd965d3be01920b481933ffc0418303
Author: Jacques Lucke
Date: Tue Mar 26 17:34:41 2019 +0100
Branches: functions
https://developer.blender.org/rB80a994776bd965d3be01920b481933ffc0418303
use multi mempool for source information
===================================================================
M source/blender/functions/core/data_flow_graph.cpp
M source/blender/functions/core/data_flow_graph.hpp
===================================================================
diff --git a/source/blender/functions/core/data_flow_graph.cpp b/source/blender/functions/core/data_flow_graph.cpp
index 469c5367834..a17da86c6e4 100644
--- a/source/blender/functions/core/data_flow_graph.cpp
+++ b/source/blender/functions/core/data_flow_graph.cpp
@@ -23,23 +23,20 @@ namespace FN {
DataFlowGraph::DataFlowGraph()
- {
- m_node_pool = new MemPool(sizeof(Node));
- }
+ : m_node_pool(sizeof(Node)) { }
DataFlowGraph::~DataFlowGraph()
{
for (Node *node : m_nodes) {
node->~Node();
}
- delete m_node_pool;
}
Node *DataFlowGraph::insert(SharedFunction &function, SourceInfo *source)
{
BLI_assert(this->can_modify());
- void *ptr = m_node_pool->allocate();
+ void *ptr = m_node_pool.allocate();
Node *node = new(ptr) Node(this, function, source);
m_nodes.add(node);
return node;
diff --git a/source/blender/functions/core/data_flow_graph.hpp b/source/blender/functions/core/data_flow_graph.hpp
index a9c19a9418b..9c00439e163 100644
--- a/source/blender/functions/core/data_flow_graph.hpp
+++ b/source/blender/functions/core/data_flow_graph.hpp
@@ -6,6 +6,7 @@
#include "BLI_small_set.hpp"
#include "BLI_small_set_vector.hpp"
#include "BLI_mempool.hpp"
+#include "BLI_multipool.hpp"
namespace FN {
@@ -63,7 +64,8 @@ namespace FN {
~Node()
{
if (m_source != nullptr) {
- delete m_source;
+ /* is allocated in mempool */
+ m_source->~SourceInfo();
}
}
@@ -260,6 +262,7 @@ namespace FN {
class DataFlowGraph : public RefCountedBase {
public:
DataFlowGraph();
+ DataFlowGraph(DataFlowGraph &other) = delete;
~DataFlowGraph();
@@ -295,7 +298,8 @@ namespace FN {
T *new_source_info(Args&&... args)
{
static_assert(std::is_base_of<SourceInfo, T>::value, "");
- T *source = new T(std::forward<Args>(args)...);
+ void *ptr = m_source_info_pool.allocate(sizeof(T));
+ T *source = new(ptr) T(std::forward<Args>(args)...);
return source;
}
@@ -306,7 +310,8 @@ namespace FN {
bool m_frozen = false;
SmallSet<Node *> m_nodes;
GraphLinks m_links;
- MemPool *m_node_pool;
+ MemPool m_node_pool;
+ MemMultiPool m_source_info_pool;
friend Node;
friend Socket;
More information about the Bf-blender-cvs
mailing list