[Bf-blender-cvs] [323c20bbb7c] functions: remove unused data structure

Jacques Lucke noreply at git.blender.org
Thu Jan 30 09:18:56 CET 2020


Commit: 323c20bbb7cdae5d1ff49ca4b4f494e168e64370
Author: Jacques Lucke
Date:   Wed Jan 29 21:18:41 2020 +0100
Branches: functions
https://developer.blender.org/rB323c20bbb7cdae5d1ff49ca4b4f494e168e64370

remove unused data structure

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

D	source/blender/blenlib/BLI_object_pool.h
M	source/blender/blenlib/CMakeLists.txt

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

diff --git a/source/blender/blenlib/BLI_object_pool.h b/source/blender/blenlib/BLI_object_pool.h
deleted file mode 100644
index 09bffe80436..00000000000
--- a/source/blender/blenlib/BLI_object_pool.h
+++ /dev/null
@@ -1,98 +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
- *
- * This structure allows reusing the same object.
- *
- * Aquire:
- *   Get an object that might have been used before.
- *   If no unused object exists currently, a new one
- *   will be allocated and constructed.
- *
- * Release:
- *   Give back the object instance, so that someone
- *   else can use it later. The destructor is not
- *   necessarily called.
- */
-
-#pragma once
-
-#include <mutex>
-
-#include "BLI_stack_cxx.h"
-#include "BLI_set.h"
-
-namespace BLI {
-
-template<typename T> class ThreadSafeObjectPool {
- private:
-  std::mutex m_mutex;
-  Stack<T *> m_free_objects;
-
-#ifdef DEBUG
-  Set<T *> m_all_objects;
-#else
-  Vector<T *> m_all_objects;
-#endif
-
- public:
-  ThreadSafeObjectPool() = default;
-  ThreadSafeObjectPool(ThreadSafeObjectPool &other) = delete;
-
-  ~ThreadSafeObjectPool()
-  {
-    BLI_assert(m_free_objects.size() == m_all_objects.size());
-    for (T *object : m_all_objects) {
-      delete object;
-    }
-  }
-
-  T *aquire()
-  {
-    std::lock_guard<std::mutex> lock(m_mutex);
-
-    if (m_free_objects.empty()) {
-      T *new_object = new T();
-      this->remember(new_object);
-      return new_object;
-    }
-    else {
-      return m_free_objects.pop();
-    }
-  }
-
-  void release(T *object)
-  {
-    std::lock_guard<std::mutex> lock(m_mutex);
-
-    BLI_assert(m_all_objects.contains(object));
-    m_free_objects.push(object);
-  }
-
- private:
-  void remember(T *object)
-  {
-#ifdef DEBUG
-    m_all_objects.add(object);
-#else
-    m_all_objects.append(object);
-#endif
-  }
-};
-
-}  // namespace BLI
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index d1e1f4276ed..83b86d265ea 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -263,7 +263,6 @@ set(SRC
   intern/BLI_lazy_init.cc
   BLI_math_cxx.h
   BLI_monotonic_allocator.h
-  BLI_object_pool.h
   BLI_optional.h
   BLI_refcount.h
   BLI_multi_map.h



More information about the Bf-blender-cvs mailing list