[Bf-blender-cvs] [9564cd045aa] functions: remove lazy init code

Jacques Lucke noreply at git.blender.org
Thu Feb 13 18:59:14 CET 2020


Commit: 9564cd045aa8985a33f49adfd57fe1dc0d4dbf0e
Author: Jacques Lucke
Date:   Thu Feb 13 18:44:50 2020 +0100
Branches: functions
https://developer.blender.org/rB9564cd045aa8985a33f49adfd57fe1dc0d4dbf0e

remove lazy init code

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

D	source/blender/blenlib/BLI_lazy_init.h
D	source/blender/blenlib/BLI_lazy_init_cxx.h
M	source/blender/blenlib/CMakeLists.txt
M	source/blender/blenlib/intern/BLI_lazy_init.cc
M	source/blender/functions/intern/multi_functions/mixed.cc
M	source/blender/functions/intern/node_tree_multi_function_network/mappings.cc
M	source/blender/simulations/bparticles/node_frontend.cpp
M	source/blender/simulations/bparticles/simulate.cpp
M	source/blender/windowmanager/intern/wm_init_exit.c
D	tests/gtests/blenlib/BLI_lazy_init_test.cc
M	tests/gtests/blenlib/CMakeLists.txt

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

diff --git a/source/blender/blenlib/BLI_lazy_init.h b/source/blender/blenlib/BLI_lazy_init.h
deleted file mode 100644
index 274072fa9d9..00000000000
--- a/source/blender/blenlib/BLI_lazy_init.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef __BLI_LAZY_INIT_H__
-#define __BLI_LAZY_INIT_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void BLI_lazy_init_free_all(void);
-void BLI_lazy_init_list_all(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __BLI_LAZY_INIT_H__ */
diff --git a/source/blender/blenlib/BLI_lazy_init_cxx.h b/source/blender/blenlib/BLI_lazy_init_cxx.h
deleted file mode 100644
index c6180a22f68..00000000000
--- a/source/blender/blenlib/BLI_lazy_init_cxx.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-/** \file
- * \ingroup bli
- *
- * These macros help to define functions that should only be
- * executed once to initialize some data. The initialized data
- * will only be freed when Blender quits.
- *
- * Requirements:
- *   - Very simple usage, without exposing the implementation details.
- *   - No additional heap allocation for every lazy initialized piece of data.
- *   - Blender has to be able to free all lazy-initialized data shortly
- *     before it quits. This is to make Blenders leak detection not detect
- *     false positives. It would, when we would just depend on static variables.
- *     These are destructed, after Blender prints non-freed memory blocks.
- */
-
-#pragma once
-
-#include <functional>
-#include <memory>
-
-#include "BLI_optional.h"
-#include "BLI_lazy_init.h"
-
-namespace BLI {
-
-void lazy_init_register(std::function<void()> free_func, const char *name);
-
-}  // namespace BLI
-
-#define BLI_LAZY_INIT(type, func_name) \
-  static type func_name##_impl(void); \
-  static type &func_name##_builder(void) \
-  { \
-    static BLI::Optional<type> value = func_name##_impl(); \
-    BLI::lazy_init_register([]() { value.reset(); }, #func_name); \
-    return value.value(); \
-  } \
-  type &func_name(void) \
-  { \
-    static type &value = func_name##_builder(); \
-    return value; \
-  } \
-  type func_name##_impl(void)
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index 24395c458e6..7252105bec0 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -257,9 +257,6 @@ set(SRC
   BLI_dot_export.h
   BLI_dot_export_attribute_enums.h
   intern/dot_export.cc
-  BLI_lazy_init.h
-  BLI_lazy_init_cxx.h
-  intern/BLI_lazy_init.cc
   BLI_math_cxx.h
   BLI_linear_allocator.h
   BLI_multi_map.h
diff --git a/source/blender/blenlib/intern/BLI_lazy_init.cc b/source/blender/blenlib/intern/BLI_lazy_init.cc
index f2f7b4ba50e..a47c72203af 100644
--- a/source/blender/blenlib/intern/BLI_lazy_init.cc
+++ b/source/blender/blenlib/intern/BLI_lazy_init.cc
@@ -16,7 +16,6 @@
 
 #include <mutex>
 
-#include "BLI_lazy_init_cxx.h"
 #include "BLI_stack_cxx.h"
 
 struct FreeFunc {
diff --git a/source/blender/functions/intern/multi_functions/mixed.cc b/source/blender/functions/intern/multi_functions/mixed.cc
index de92be0fe06..53e61ce36f3 100644
--- a/source/blender/functions/intern/multi_functions/mixed.cc
+++ b/source/blender/functions/intern/multi_functions/mixed.cc
@@ -5,7 +5,6 @@
 #include "FN_multi_function_common_contexts.h"
 
 #include "BLI_math_cxx.h"
-#include "BLI_lazy_init_cxx.h"
 #include "BLI_string_map.h"
 #include "BLI_array_cxx.h"
 #include "BLI_noise.h"
diff --git a/source/blender/functions/intern/node_tree_multi_function_network/mappings.cc b/source/blender/functions/intern/node_tree_multi_function_network/mappings.cc
index 139f981c376..dee4f32ddd0 100644
--- a/source/blender/functions/intern/node_tree_multi_function_network/mappings.cc
+++ b/source/blender/functions/intern/node_tree_multi_function_network/mappings.cc
@@ -1,6 +1,5 @@
 #include "mappings.h"
 
-#include "BLI_lazy_init_cxx.h"
 #include "BLI_math_cxx.h"
 
 #include "FN_multi_functions.h"
diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp
index beb3742227e..ca139382527 100644
--- a/source/blender/simulations/bparticles/node_frontend.cpp
+++ b/source/blender/simulations/bparticles/node_frontend.cpp
@@ -8,7 +8,6 @@
 #include "BLI_timeit.h"
 #include "BLI_multi_map.h"
 #include "BLI_set.h"
-#include "BLI_lazy_init_cxx.h"
 
 #include "FN_node_tree.h"
 #include "FN_multi_functions.h"
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index 24af6827365..22d3752343f 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -1,5 +1,4 @@
 
-#include "BLI_lazy_init_cxx.h"
 #include "BLI_timeit.h"
 #include "BLI_array_cxx.h"
 #include "BLI_vector_adaptor.h"
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 76302696f1f..8eb27b21ba9 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -47,7 +47,6 @@
 #include "BLI_threads.h"
 #include "BLI_utildefines.h"
 #include "BLI_timer.h"
-#include "BLI_lazy_init.h"
 
 #include "BLO_writefile.h"
 #include "BLO_undofile.h"
@@ -531,7 +530,6 @@ void WM_exit_ex(bContext *C, const bool do_python)
   }
 
   BLI_timer_free();
-  BLI_lazy_init_free_all();
 
   WM_paneltype_clear();
 
diff --git a/tests/gtests/blenlib/BLI_lazy_init_test.cc b/tests/gtests/blenlib/BLI_lazy_init_test.cc
deleted file mode 100644
index 1e066c3c4b6..00000000000
--- a/tests/gtests/blenlib/BLI_lazy_init_test.cc
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "testing/testing.h"
-#include "BLI_lazy_init_cxx.h"
-
-BLI_LAZY_INIT(void *, get_single_pointer)
-{
-  return std::malloc(42);
-}
-
-TEST(lazy_init, NoArg_ReturnSame)
-{
-  void *ptr1 = get_single_pointer();
-  void *ptr2 = get_single_pointer();
-  EXPECT_EQ(ptr1, ptr2);
-}
diff --git a/tests/gtests/blenlib/CMakeLists.txt b/tests/gtests/blenlib/CMakeLists.txt
index ff8dd7b0e9b..cf36225dca8 100644
--- a/tests/gtests/blenlib/CMakeLists.txt
+++ b/tests/gtests/blenlib/CMakeLists.txt
@@ -52,7 +52,6 @@ BLENDER_TEST(BLI_heap "bf_blenlib")
 BLENDER_TEST(BLI_heap_simple "bf_blenlib")
 BLENDER_TEST(BLI_index_range "bf_blenlib")
 BLENDER_TEST(BLI_kdopbvh "bf_blenlib;bf_intern_numaapi")
-BLENDER_TEST(BLI_lazy_init "bf_blenlib")
 BLENDER_TEST(BLI_linklist_lockfree "bf_blenlib;bf_intern_numaapi")
 BLENDER_TEST(BLI_listbase "bf_blenlib")
 BLENDER_TEST(BLI_map "bf_blenlib")



More information about the Bf-blender-cvs mailing list