aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbugaevskiy <bugaevskiy@yandex-team.com>2022-08-24 10:46:36 +0300
committerbugaevskiy <bugaevskiy@yandex-team.com>2022-08-24 10:46:36 +0300
commit60efd6a481feccd39ce6cc2dd013eb4f28419bc6 (patch)
tree0c20ff937c2475e16b5f9a591b846020fa8fb2a6
parentebeeef7964fdf94b17cb0b178e74d2bc25632dad (diff)
downloadydb-60efd6a481feccd39ce6cc2dd013eb4f28419bc6.tar.gz
Reimport boost/pool as a separate project
-rw-r--r--CMakeLists.darwin.txt1
-rw-r--r--CMakeLists.linux.txt1
-rw-r--r--contrib/restricted/boost/CMakeLists.txt1
-rw-r--r--contrib/restricted/boost/boost/pool/detail/guard.hpp69
-rw-r--r--contrib/restricted/boost/boost/pool/detail/mutex.hpp50
-rw-r--r--contrib/restricted/boost/boost/pool/detail/pool_construct.ipp852
-rw-r--r--contrib/restricted/boost/boost/pool/detail/pool_construct_simple.ipp43
-rw-r--r--contrib/restricted/boost/boost/pool/object_pool.hpp287
-rw-r--r--contrib/restricted/boost/boost/pool/pool.hpp1024
-rw-r--r--contrib/restricted/boost/boost/pool/pool_alloc.hpp512
-rw-r--r--contrib/restricted/boost/boost/pool/poolfwd.hpp82
-rw-r--r--contrib/restricted/boost/boost/pool/simple_segregated_storage.hpp377
-rw-r--r--contrib/restricted/boost/boost/pool/singleton_pool.hpp251
-rw-r--r--contrib/restricted/boost/pool/CMakeLists.txt22
14 files changed, 25 insertions, 3547 deletions
diff --git a/CMakeLists.darwin.txt b/CMakeLists.darwin.txt
index 517f73681e0..b45a2d34af1 100644
--- a/CMakeLists.darwin.txt
+++ b/CMakeLists.darwin.txt
@@ -337,6 +337,7 @@ add_subdirectory(contrib/restricted/boost/rational)
add_subdirectory(contrib/restricted/boost/phoenix)
add_subdirectory(contrib/restricted/boost/proto)
add_subdirectory(contrib/restricted/boost/polygon)
+add_subdirectory(contrib/restricted/boost/pool)
add_subdirectory(contrib/restricted/boost/qvm)
add_subdirectory(contrib/restricted/boost/tokenizer)
add_subdirectory(contrib/restricted/boost/tti)
diff --git a/CMakeLists.linux.txt b/CMakeLists.linux.txt
index af86c200ca5..5a0aa105298 100644
--- a/CMakeLists.linux.txt
+++ b/CMakeLists.linux.txt
@@ -340,6 +340,7 @@ add_subdirectory(contrib/restricted/boost/rational)
add_subdirectory(contrib/restricted/boost/phoenix)
add_subdirectory(contrib/restricted/boost/proto)
add_subdirectory(contrib/restricted/boost/polygon)
+add_subdirectory(contrib/restricted/boost/pool)
add_subdirectory(contrib/restricted/boost/qvm)
add_subdirectory(contrib/restricted/boost/tokenizer)
add_subdirectory(contrib/restricted/boost/tti)
diff --git a/contrib/restricted/boost/CMakeLists.txt b/contrib/restricted/boost/CMakeLists.txt
index 9dbe212fbca..fbe9ff78159 100644
--- a/contrib/restricted/boost/CMakeLists.txt
+++ b/contrib/restricted/boost/CMakeLists.txt
@@ -53,6 +53,7 @@ target_link_libraries(contrib-restricted-boost INTERFACE
restricted-boost-parameter
restricted-boost-phoenix
restricted-boost-polygon
+ restricted-boost-pool
restricted-boost-predef
restricted-boost-preprocessor
restricted-boost-proto
diff --git a/contrib/restricted/boost/boost/pool/detail/guard.hpp b/contrib/restricted/boost/boost/pool/detail/guard.hpp
deleted file mode 100644
index 3d155ffb2e2..00000000000
--- a/contrib/restricted/boost/boost/pool/detail/guard.hpp
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright (C) 2000 Stephen Cleary
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org for updates, documentation, and revision history.
-
-#ifndef BOOST_POOL_GUARD_HPP
-#define BOOST_POOL_GUARD_HPP
-
-/*!
- \file
- \brief Extremely Light-Weight guard class.
- \details Auto-lock/unlock-er
- detail/guard.hpp provides a type guard<Mutex>
- that allows scoped access to the Mutex's locking and unlocking operations.
- It is used to ensure that a Mutex is unlocked, even if an exception is thrown.
-*/
-
-namespace boost {
-
-namespace details {
-namespace pool {
-
-template <typename Mutex> //!< \tparam Mutex (platform-specific) mutex class.
-class guard
-{ //! Locks the mutex, binding guard<Mutex> to Mutex.
- /*! Example:
- Given a (platform-specific) mutex class, we can wrap code as follows:
-
- extern mutex global_lock;
-
- static void f()
- {
- boost::details::pool::guard<mutex> g(global_lock);
- // g's constructor locks "global_lock"
-
- ... // do anything:
- // throw exceptions
- // return
- // or just fall through
- } // g's destructor unlocks "global_lock"
- */
- private:
- Mutex & mtx;
-
- guard(const guard &); //!< Guards the mutex, ensuring unlocked on destruction, even if exception is thrown.
- void operator=(const guard &);
-
- public:
- explicit guard(Mutex & nmtx)
- :mtx(nmtx)
- { //! Locks the mutex of the guard class.
- mtx.lock();
- }
-
- ~guard()
- { //! destructor unlocks the mutex of the guard class.
- mtx.unlock();
- }
-}; // class guard
-
-} // namespace pool
-} // namespace details
-
-} // namespace boost
-
-#endif
diff --git a/contrib/restricted/boost/boost/pool/detail/mutex.hpp b/contrib/restricted/boost/boost/pool/detail/mutex.hpp
deleted file mode 100644
index 8d9b1d5627b..00000000000
--- a/contrib/restricted/boost/boost/pool/detail/mutex.hpp
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (C) 2000 Stephen Cleary
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org for updates, documentation, and revision history.
-
-#ifndef BOOST_POOL_MUTEX_HPP
-#define BOOST_POOL_MUTEX_HPP
-
-#include <boost/config.hpp> // for workarounds
-#if defined (BOOST_HAS_THREADS) && !defined(BOOST_POOL_NO_MT)
-#if defined (BOOST_NO_CXX11_HDR_MUTEX)
-#include <boost/thread/mutex.hpp>
-#else
-#include <mutex>
-#endif
-#endif
-
-namespace boost{ namespace details{ namespace pool{
-
-class null_mutex
-{
- private:
- null_mutex(const null_mutex &);
- void operator=(const null_mutex &);
-
- public:
- null_mutex() { }
-
- static void lock() { }
- static void unlock() { }
-};
-
-#if !defined(BOOST_HAS_THREADS) || defined(BOOST_NO_MT) || defined(BOOST_POOL_NO_MT)
- typedef null_mutex default_mutex;
-#else
-#if defined (BOOST_NO_CXX11_HDR_MUTEX)
- typedef boost::mutex default_mutex;
-#else
- typedef std::mutex default_mutex;
-#endif
-#endif
-
-} // namespace pool
-} // namespace details
-} // namespace boost
-
-#endif
diff --git a/contrib/restricted/boost/boost/pool/detail/pool_construct.ipp b/contrib/restricted/boost/boost/pool/detail/pool_construct.ipp
deleted file mode 100644
index 81107b0412a..00000000000
--- a/contrib/restricted/boost/boost/pool/detail/pool_construct.ipp
+++ /dev/null
@@ -1,852 +0,0 @@
-// Copyright (C) 2000 Stephen Cleary
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompany-
-// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org for updates, documentation, and revision history.
-
-// This file was AUTOMATICALLY GENERATED from "stdin"
-// Do NOT include directly!
-// Do NOT edit!
-
-template <typename T0>
-element_type * construct(T0 & a0)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0>
-element_type * construct(const T0 & a0)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0>
-element_type * construct(volatile T0 & a0)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0>
-element_type * construct(const volatile T0 & a0)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1>
-element_type * construct(T0 & a0, T1 & a1)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1>
-element_type * construct(const T0 & a0, T1 & a1)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1>
-element_type * construct(volatile T0 & a0, T1 & a1)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1>
-element_type * construct(const volatile T0 & a0, T1 & a1)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1>
-element_type * construct(T0 & a0, const T1 & a1)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1>
-element_type * construct(const T0 & a0, const T1 & a1)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1>
-element_type * construct(volatile T0 & a0, const T1 & a1)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1>
-element_type * construct(const volatile T0 & a0, const T1 & a1)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1>
-element_type * construct(T0 & a0, volatile T1 & a1)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1>
-element_type * construct(const T0 & a0, volatile T1 & a1)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1>
-element_type * construct(volatile T0 & a0, volatile T1 & a1)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1>
-element_type * construct(const volatile T0 & a0, volatile T1 & a1)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1>
-element_type * construct(T0 & a0, const volatile T1 & a1)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1>
-element_type * construct(const T0 & a0, const volatile T1 & a1)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1>
-element_type * construct(volatile T0 & a0, const volatile T1 & a1)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1>
-element_type * construct(const volatile T0 & a0, const volatile T1 & a1)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(T0 & a0, T1 & a1, T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const T0 & a0, T1 & a1, T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(volatile T0 & a0, T1 & a1, T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const volatile T0 & a0, T1 & a1, T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(T0 & a0, const T1 & a1, T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const T0 & a0, const T1 & a1, T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(volatile T0 & a0, const T1 & a1, T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const volatile T0 & a0, const T1 & a1, T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(T0 & a0, volatile T1 & a1, T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const T0 & a0, volatile T1 & a1, T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(volatile T0 & a0, volatile T1 & a1, T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const volatile T0 & a0, volatile T1 & a1, T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(T0 & a0, const volatile T1 & a1, T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const T0 & a0, const volatile T1 & a1, T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(volatile T0 & a0, const volatile T1 & a1, T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const volatile T0 & a0, const volatile T1 & a1, T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(T0 & a0, T1 & a1, const T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const T0 & a0, T1 & a1, const T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(volatile T0 & a0, T1 & a1, const T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const volatile T0 & a0, T1 & a1, const T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(T0 & a0, const T1 & a1, const T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const T0 & a0, const T1 & a1, const T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(volatile T0 & a0, const T1 & a1, const T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const volatile T0 & a0, const T1 & a1, const T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(T0 & a0, volatile T1 & a1, const T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const T0 & a0, volatile T1 & a1, const T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(volatile T0 & a0, volatile T1 & a1, const T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const volatile T0 & a0, volatile T1 & a1, const T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(T0 & a0, const volatile T1 & a1, const T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const T0 & a0, const volatile T1 & a1, const T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(volatile T0 & a0, const volatile T1 & a1, const T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const volatile T0 & a0, const volatile T1 & a1, const T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(T0 & a0, T1 & a1, volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const T0 & a0, T1 & a1, volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(volatile T0 & a0, T1 & a1, volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const volatile T0 & a0, T1 & a1, volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(T0 & a0, const T1 & a1, volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const T0 & a0, const T1 & a1, volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(volatile T0 & a0, const T1 & a1, volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const volatile T0 & a0, const T1 & a1, volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(T0 & a0, volatile T1 & a1, volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const T0 & a0, volatile T1 & a1, volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(volatile T0 & a0, volatile T1 & a1, volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const volatile T0 & a0, volatile T1 & a1, volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(T0 & a0, const volatile T1 & a1, volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const T0 & a0, const volatile T1 & a1, volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(volatile T0 & a0, const volatile T1 & a1, volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const volatile T0 & a0, const volatile T1 & a1, volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(T0 & a0, T1 & a1, const volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const T0 & a0, T1 & a1, const volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(volatile T0 & a0, T1 & a1, const volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const volatile T0 & a0, T1 & a1, const volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(T0 & a0, const T1 & a1, const volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const T0 & a0, const T1 & a1, const volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(volatile T0 & a0, const T1 & a1, const volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const volatile T0 & a0, const T1 & a1, const volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(T0 & a0, volatile T1 & a1, const volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const T0 & a0, volatile T1 & a1, const volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(volatile T0 & a0, volatile T1 & a1, const volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const volatile T0 & a0, volatile T1 & a1, const volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(T0 & a0, const volatile T1 & a1, const volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const T0 & a0, const volatile T1 & a1, const volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(volatile T0 & a0, const volatile T1 & a1, const volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const volatile T0 & a0, const volatile T1 & a1, const volatile T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-
diff --git a/contrib/restricted/boost/boost/pool/detail/pool_construct_simple.ipp b/contrib/restricted/boost/boost/pool/detail/pool_construct_simple.ipp
deleted file mode 100644
index 2627640aa88..00000000000
--- a/contrib/restricted/boost/boost/pool/detail/pool_construct_simple.ipp
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (C) 2000 Stephen Cleary
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org for updates, documentation, and revision history.
-
-// This file was AUTOMATICALLY GENERATED from "stdin"
-// Do NOT include directly!
-// Do NOT edit!
-
-template <typename T0>
-element_type * construct(const T0 & a0)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1>
-element_type * construct(const T0 & a0, const T1 & a1)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-template <typename T0, typename T1, typename T2>
-element_type * construct(const T0 & a0, const T1 & a1, const T2 & a2)
-{
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(a0, a1, a2); }
- catch (...) { (free)(ret); throw; }
- return ret;
-}
-
diff --git a/contrib/restricted/boost/boost/pool/object_pool.hpp b/contrib/restricted/boost/boost/pool/object_pool.hpp
deleted file mode 100644
index 092f0178734..00000000000
--- a/contrib/restricted/boost/boost/pool/object_pool.hpp
+++ /dev/null
@@ -1,287 +0,0 @@
-// Copyright (C) 2000, 2001 Stephen Cleary
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org for updates, documentation, and revision history.
-
-#ifndef BOOST_OBJECT_POOL_HPP
-#define BOOST_OBJECT_POOL_HPP
-/*!
-\file
-\brief Provides a template type boost::object_pool<T, UserAllocator>
-that can be used for fast and efficient memory allocation of objects of type T.
-It also provides automatic destruction of non-deallocated objects.
-*/
-
-#include <boost/pool/poolfwd.hpp>
-
-// boost::pool
-#include <boost/pool/pool.hpp>
-
-// The following code will be put into Boost.Config in a later revision
-#if defined(BOOST_MSVC) || defined(__KCC)
-# define BOOST_NO_TEMPLATE_CV_REF_OVERLOADS
-#endif
-
-// The following code might be put into some Boost.Config header in a later revision
-#ifdef __BORLANDC__
-# pragma option push -w-inl
-#endif
-
-// There are a few places in this file where the expression "this->m" is used.
-// This expression is used to force instantiation-time name lookup, which I am
-// informed is required for strict Standard compliance. It's only necessary
-// if "m" is a member of a base class that is dependent on a template
-// parameter.
-// Thanks to Jens Maurer for pointing this out!
-
-namespace boost {
-
-/*! \brief A template class
-that can be used for fast and efficient memory allocation of objects.
-It also provides automatic destruction of non-deallocated objects.
-
-\details
-
-<b>T</b> The type of object to allocate/deallocate.
-T must have a non-throwing destructor.
-
-<b>UserAllocator</b>
-Defines the allocator that the underlying Pool will use to allocate memory from the system.
-See <a href="boost_pool/pool/pooling.html#boost_pool.pool.pooling.user_allocator">User Allocators</a> for details.
-
-Class object_pool is a template class
-that can be used for fast and efficient memory allocation of objects.
-It also provides automatic destruction of non-deallocated objects.
-
-When the object pool is destroyed, then the destructor for type T
-is called for each allocated T that has not yet been deallocated. O(N).
-
-Whenever an object of type ObjectPool needs memory from the system,
-it will request it from its UserAllocator template parameter.
-The amount requested is determined using a doubling algorithm;
-that is, each time more system memory is allocated,
-the amount of system memory requested is doubled.
-Users may control the doubling algorithm by the parameters passed
-to the object_pool's constructor.
-*/
-
-template <typename T, typename UserAllocator>
-class object_pool: protected pool<UserAllocator>
-{ //!
- public:
- typedef T element_type; //!< ElementType
- typedef UserAllocator user_allocator; //!<
- typedef typename pool<UserAllocator>::size_type size_type; //!< pool<UserAllocator>::size_type
- typedef typename pool<UserAllocator>::difference_type difference_type; //!< pool<UserAllocator>::difference_type
-
- protected:
- //! \return The underlying boost:: \ref pool storage used by *this.
- pool<UserAllocator> & store()
- {
- return *this;
- }
- //! \return The underlying boost:: \ref pool storage used by *this.
- const pool<UserAllocator> & store() const
- {
- return *this;
- }
-
- // for the sake of code readability :)
- static void * & nextof(void * const ptr)
- { //! \returns The next memory block after ptr (for the sake of code readability :)
- return *(static_cast<void **>(ptr));
- }
-
- public:
- explicit object_pool(const size_type arg_next_size = 32, const size_type arg_max_size = 0)
- :
- pool<UserAllocator>(sizeof(T), arg_next_size, arg_max_size)
- { //! Constructs a new (empty by default) ObjectPool.
- //! \param next_size Number of chunks to request from the system the next time that object needs to allocate system memory (default 32).
- //! \pre next_size != 0.
- //! \param max_size Maximum number of chunks to ever request from the system - this puts a cap on the doubling algorithm
- //! used by the underlying pool.
- }
-
- ~object_pool();
-
- // Returns 0 if out-of-memory.
- element_type * malloc BOOST_PREVENT_MACRO_SUBSTITUTION()
- { //! Allocates memory that can hold one object of type ElementType.
- //!
- //! If out of memory, returns 0.
- //!
- //! Amortized O(1).
- return static_cast<element_type *>(store().ordered_malloc());
- }
- void free BOOST_PREVENT_MACRO_SUBSTITUTION(element_type * const chunk)
- { //! De-Allocates memory that holds a chunk of type ElementType.
- //!
- //! Note that p may not be 0.\n
- //!
- //! Note that the destructor for p is not called. O(N).
- store().ordered_free(chunk);
- }
- bool is_from(element_type * const chunk) const
- { /*! \returns true if chunk was allocated from *this or
- may be returned as the result of a future allocation from *this.
-
- Returns false if chunk was allocated from some other pool or
- may be returned as the result of a future allocation from some other pool.
-
- Otherwise, the return value is meaningless.
-
- \note This function may NOT be used to reliably test random pointer values!
- */
- return store().is_from(chunk);
- }
-
- element_type * construct()
- { //! \returns A pointer to an object of type T, allocated in memory from the underlying pool
- //! and default constructed. The returned objected can be freed by a call to \ref destroy.
- //! Otherwise the returned object will be automatically destroyed when *this is destroyed.
- element_type * const ret = (malloc)();
- if (ret == 0)
- return ret;
- try { new (ret) element_type(); }
- catch (...) { (free)(ret); throw; }
- return ret;
- }
-
-
-#if defined(BOOST_DOXYGEN)
- template <class Arg1, ... class ArgN>
- element_type * construct(Arg1&, ... ArgN&)
- {
- //! \returns A pointer to an object of type T, allocated in memory from the underlying pool
- //! and constructed from arguments Arg1 to ArgN. The returned objected can be freed by a call to \ref destroy.
- //! Otherwise the returned object will be automatically destroyed when *this is destroyed.
- //!
- //! \note Since the number and type of arguments to this function is totally arbitrary, a simple system has been
- //! set up to automatically generate template construct functions. This system is based on the macro preprocessor
- //! m4, which is standard on UNIX systems and also available for Win32 systems.\n\n
- //! detail/pool_construct.m4, when run with m4, will create the file detail/pool_construct.ipp, which only defines
- //! the construct functions for the proper number of arguments. The number of arguments may be passed into the
- //! file as an m4 macro, NumberOfArguments; if not provided, it will default to 3.\n\n
- //! For each different number of arguments (1 to NumberOfArguments), a template function is generated. There
- //! are the same number of template parameters as there are arguments, and each argument's type is a reference
- //! to that (possibly cv-qualified) template argument. Each possible permutation of the cv-qualifications is also generated.\n\n
- //! Because each permutation is generated for each possible number of arguments, the included file size grows
- //! exponentially in terms of the number of constructor arguments, not linearly. For the sake of rational
- //! compile times, only use as many arguments as you need.\n\n
- //! detail/pool_construct.bat and detail/pool_construct.sh are also provided to call m4, defining NumberOfArguments
- //! to be their command-line parameter. See these files for more details.
- }
-#else
-// Include automatically-generated file for family of template construct() functions.
-// Copy .inc renamed .ipp to conform to Doxygen include filename expectations, PAB 12 Jan 11.
-// But still get Doxygen warning:
-// I:/boost-sandbox/guild/pool/boost/pool/object_pool.hpp:82:
-// Warning: include file boost/pool/detail/pool_construct.ipp
-// not found, perhaps you forgot to add its directory to INCLUDE_PATH?
-// But the file IS found and referenced OK, but cannot view code.
-// This seems because not at the head of the file
-// But if moved this up, Doxygen is happy, but of course it won't compile,
-// because the many constructors *must* go here.
-
-#ifndef BOOST_NO_TEMPLATE_CV_REF_OVERLOADS
-# include <boost/pool/detail/pool_construct.ipp>
-#else
-# include <boost/pool/detail/pool_construct_simple.ipp>
-#endif
-#endif
- void destroy(element_type * const chunk)
- { //! Destroys an object allocated with \ref construct.
- //!
- //! Equivalent to:
- //!
- //! p->~ElementType(); this->free(p);
- //!
- //! \pre p must have been previously allocated from *this via a call to \ref construct.
- chunk->~T();
- (free)(chunk);
- }
-
- size_type get_next_size() const
- { //! \returns The number of chunks that will be allocated next time we run out of memory.
- return store().get_next_size();
- }
- void set_next_size(const size_type x)
- { //! Set a new number of chunks to allocate the next time we run out of memory.
- //! \param x wanted next_size (must not be zero).
- store().set_next_size(x);
- }
-};
-
-template <typename T, typename UserAllocator>
-object_pool<T, UserAllocator>::~object_pool()
-{
-#ifndef BOOST_POOL_VALGRIND
- // handle trivial case of invalid list.
- if (!this->list.valid())
- return;
-
- details::PODptr<size_type> iter = this->list;
- details::PODptr<size_type> next = iter;
-
- // Start 'freed_iter' at beginning of free list
- void * freed_iter = this->first;
-
- const size_type partition_size = this->alloc_size();
-
- do
- {
- // increment next
- next = next.next();
-
- // delete all contained objects that aren't freed.
-
- // Iterate 'i' through all chunks in the memory block.
- for (char * i = iter.begin(); i != iter.end(); i += partition_size)
- {
- // If this chunk is free,
- if (i == freed_iter)
- {
- // Increment freed_iter to point to next in free list.
- freed_iter = nextof(freed_iter);
-
- // Continue searching chunks in the memory block.
- continue;
- }
-
- // This chunk is not free (allocated), so call its destructor,
- static_cast<T *>(static_cast<void *>(i))->~T();
- // and continue searching chunks in the memory block.
- }
-
- // free storage.
- (UserAllocator::free)(iter.begin());
-
- // increment iter.
- iter = next;
- } while (iter.valid());
-
- // Make the block list empty so that the inherited destructor doesn't try to
- // free it again.
- this->list.invalidate();
-#else
- // destruct all used elements:
- for(std::set<void*>::iterator pos = this->used_list.begin(); pos != this->used_list.end(); ++pos)
- {
- static_cast<T*>(*pos)->~T();
- }
- // base class will actually free the memory...
-#endif
-}
-
-} // namespace boost
-
-// The following code might be put into some Boost.Config header in a later revision
-#ifdef __BORLANDC__
-# pragma option pop
-#endif
-
-#endif
diff --git a/contrib/restricted/boost/boost/pool/pool.hpp b/contrib/restricted/boost/boost/pool/pool.hpp
deleted file mode 100644
index c47b11faf20..00000000000
--- a/contrib/restricted/boost/boost/pool/pool.hpp
+++ /dev/null
@@ -1,1024 +0,0 @@
-// Copyright (C) 2000, 2001 Stephen Cleary
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org for updates, documentation, and revision history.
-
-#ifndef BOOST_POOL_HPP
-#define BOOST_POOL_HPP
-
-#include <boost/config.hpp> // for workarounds
-
-// std::less, std::less_equal, std::greater
-#include <functional>
-// new[], delete[], std::nothrow
-#include <new>
-// std::size_t, std::ptrdiff_t
-#include <cstddef>
-// std::malloc, std::free
-#include <cstdlib>
-// std::invalid_argument
-#include <exception>
-// std::max
-#include <algorithm>
-
-#include <boost/pool/poolfwd.hpp>
-
-// boost::integer::static_lcm
-#include <boost/integer/common_factor_ct.hpp>
-// boost::simple_segregated_storage
-#include <boost/pool/simple_segregated_storage.hpp>
-// boost::alignment_of
-#include <boost/type_traits/alignment_of.hpp>
-// BOOST_ASSERT
-#include <boost/assert.hpp>
-
-#ifdef BOOST_POOL_INSTRUMENT
-#include <iostream>
-#include<iomanip>
-#endif
-#ifdef BOOST_POOL_VALGRIND
-#include <set>
-#include <valgrind/memcheck.h>
-#endif
-
-#ifdef BOOST_NO_STDC_NAMESPACE
- namespace std { using ::malloc; using ::free; }
-#endif
-
-// There are a few places in this file where the expression "this->m" is used.
-// This expression is used to force instantiation-time name lookup, which I am
-// informed is required for strict Standard compliance. It's only necessary
-// if "m" is a member of a base class that is dependent on a template
-// parameter.
-// Thanks to Jens Maurer for pointing this out!
-
-/*!
- \file
- \brief Provides class \ref pool: a fast memory allocator that guarantees proper alignment of all allocated chunks,
- and which extends and generalizes the framework provided by the simple segregated storage solution.
- Also provides two UserAllocator classes which can be used in conjuction with \ref pool.
-*/
-
-/*!
- \mainpage Boost.Pool Memory Allocation Scheme
-
- \section intro_sec Introduction
-
- Pool allocation is a memory allocation scheme that is very fast, but limited in its usage.
-
- This Doxygen-style documentation is complementary to the
- full Quickbook-generated html and pdf documentation at www.boost.org.
-
- This page generated from file pool.hpp.
-
-*/
-
-#ifdef BOOST_MSVC
-#pragma warning(push)
-#pragma warning(disable:4127) // Conditional expression is constant
-#endif
-
- namespace boost
-{
-
-//! \brief Allocator used as the default template parameter for
-//! a <a href="boost_pool/pool/pooling.html#boost_pool.pool.pooling.user_allocator">UserAllocator</a>
-//! template parameter. Uses new and delete.
-struct default_user_allocator_new_delete
-{
- typedef std::size_t size_type; //!< An unsigned integral type that can represent the size of the largest object to be allocated.
- typedef std::ptrdiff_t difference_type; //!< A signed integral type that can represent the difference of any two pointers.
-
- static char * malloc BOOST_PREVENT_MACRO_SUBSTITUTION(const size_type bytes)
- { //! Attempts to allocate n bytes from the system. Returns 0 if out-of-memory
- return new (std::nothrow) char[bytes];
- }
- static void free BOOST_PREVENT_MACRO_SUBSTITUTION(char * const block)
- { //! Attempts to de-allocate block.
- //! \pre Block must have been previously returned from a call to UserAllocator::malloc.
- delete [] block;
- }
-};
-
-//! \brief <a href="boost_pool/pool/pooling.html#boost_pool.pool.pooling.user_allocator">UserAllocator</a>
-//! used as template parameter for \ref pool and \ref object_pool.
-//! Uses malloc and free internally.
-struct default_user_allocator_malloc_free
-{
- typedef std::size_t size_type; //!< An unsigned integral type that can represent the size of the largest object to be allocated.
- typedef std::ptrdiff_t difference_type; //!< A signed integral type that can represent the difference of any two pointers.
-
- static char * malloc BOOST_PREVENT_MACRO_SUBSTITUTION(const size_type bytes)
- { return static_cast<char *>((std::malloc)(bytes)); }
- static void free BOOST_PREVENT_MACRO_SUBSTITUTION(char * const block)
- { (std::free)(block); }
-};
-
-namespace details
-{ //! Implemention only.
-
-template <typename SizeType>
-class PODptr
-{ //! PODptr is a class that pretends to be a "pointer" to different class types
- //! that don't really exist. It provides member functions to access the "data"
- //! of the "object" it points to. Since these "class" types are of variable
- //! size, and contains some information at the *end* of its memory
- //! (for alignment reasons),
- //! PODptr must contain the size of this "class" as well as the pointer to this "object".
-
- /*! \details A PODptr holds the location and size of a memory block allocated from the system.
- Each memory block is split logically into three sections:
-
- <b>Chunk area</b>. This section may be different sizes. PODptr does not care what the size of the chunks is,
- but it does care (and keep track of) the total size of the chunk area.
-
- <b>Next pointer</b>. This section is always the same size for a given SizeType. It holds a pointer
- to the location of the next memory block in the memory block list, or 0 if there is no such block.
-
- <b>Next size</b>. This section is always the same size for a given SizeType. It holds the size of the
- next memory block in the memory block list.
-
-The PODptr class just provides cleaner ways of dealing with raw memory blocks.
-
-A PODptr object is either valid or invalid. An invalid PODptr is analogous to a null pointer.
-The default constructor for PODptr will result in an invalid object.
-Calling the member function invalidate will result in that object becoming invalid.
-The member function valid can be used to test for validity.
-*/
- public:
- typedef SizeType size_type;
-
- private:
- char * ptr;
- size_type sz;
-
- char * ptr_next_size() const
- {
- return (ptr + sz - sizeof(size_type));
- }
- char * ptr_next_ptr() const
- {
- return (ptr_next_size() -
- integer::static_lcm<sizeof(size_type), sizeof(void *)>::value);
- }
-
- public:
- PODptr(char * const nptr, const size_type nsize)
- :ptr(nptr), sz(nsize)
- {
- //! A PODptr may be created to point to a memory block by passing
- //! the address and size of that memory block into the constructor.
- //! A PODptr constructed in this way is valid.
- }
- PODptr()
- : ptr(0), sz(0)
- { //! default constructor for PODptr will result in an invalid object.
- }
-
- bool valid() const
- { //! A PODptr object is either valid or invalid.
- //! An invalid PODptr is analogous to a null pointer.
- //! \returns true if PODptr is valid, false if invalid.
- return (begin() != 0);
- }
- void invalidate()
- { //! Make object invalid.
- begin() = 0;
- }
- char * & begin()
- { //! Each PODptr keeps the address and size of its memory block.
- //! \returns The address of its memory block.
- return ptr;
- }
- char * begin() const
- { //! Each PODptr keeps the address and size of its memory block.
- //! \return The address of its memory block.
- return ptr;
- }
- char * end() const
- { //! \returns begin() plus element_size (a 'past the end' value).
- return ptr_next_ptr();
- }
- size_type total_size() const
- { //! Each PODptr keeps the address and size of its memory block.
- //! The address may be read or written by the member functions begin.
- //! The size of the memory block may only be read,
- //! \returns size of the memory block.
- return sz;
- }
- size_type element_size() const
- { //! \returns size of element pointer area.
- return static_cast<size_type>(sz - sizeof(size_type) -
- integer::static_lcm<sizeof(size_type), sizeof(void *)>::value);
- }
-
- size_type & next_size() const
- { //!
- //! \returns next_size.
- return *(static_cast<size_type *>(static_cast<void*>((ptr_next_size()))));
- }
- char * & next_ptr() const
- { //! \returns pointer to next pointer area.
- return *(static_cast<char **>(static_cast<void*>(ptr_next_ptr())));
- }
-
- PODptr next() const
- { //! \returns next PODptr.
- return PODptr<size_type>(next_ptr(), next_size());
- }
- void next(const PODptr & arg) const
- { //! Sets next PODptr.
- next_ptr() = arg.begin();
- next_size() = arg.total_size();
- }
-}; // class PODptr
-} // namespace details
-
-#ifndef BOOST_POOL_VALGRIND
-/*!
- \brief A fast memory allocator that guarantees proper alignment of all allocated chunks.
-
- \details Whenever an object of type pool needs memory from the system,
- it will request it from its UserAllocator template parameter.
- The amount requested is determined using a doubling algorithm;
- that is, each time more system memory is allocated,
- the amount of system memory requested is doubled.
-
- Users may control the doubling algorithm by using the following extensions:
-
- Users may pass an additional constructor parameter to pool.
- This parameter is of type size_type,
- and is the number of chunks to request from the system
- the first time that object needs to allocate system memory.
- The default is 32. This parameter may not be 0.
-
- Users may also pass an optional third parameter to pool's
- constructor. This parameter is of type size_type,
- and sets a maximum size for allocated chunks. When this
- parameter takes the default value of 0, then there is no upper
- limit on chunk size.
-
- Finally, if the doubling algorithm results in no memory
- being allocated, the pool will backtrack just once, halving
- the chunk size and trying again.
-
- <b>UserAllocator type</b> - the method that the Pool will use to allocate memory from the system.
-
- There are essentially two ways to use class pool: the client can call \ref malloc() and \ref free() to allocate
- and free single chunks of memory, this is the most efficient way to use a pool, but does not allow for
- the efficient allocation of arrays of chunks. Alternatively, the client may call \ref ordered_malloc() and \ref
- ordered_free(), in which case the free list is maintained in an ordered state, and efficient allocation of arrays
- of chunks are possible. However, this latter option can suffer from poor performance when large numbers of
- allocations are performed.
-
-*/
-template <typename UserAllocator>
-class pool: protected simple_segregated_storage < typename UserAllocator::size_type >
-{
- public:
- typedef UserAllocator user_allocator; //!< User allocator.
- typedef typename UserAllocator::size_type size_type; //!< An unsigned integral type that can represent the size of the largest object to be allocated.
- typedef typename UserAllocator::difference_type difference_type; //!< A signed integral type that can represent the difference of any two pointers.
-
- private:
- BOOST_STATIC_CONSTANT(size_type, min_alloc_size =
- (::boost::integer::static_lcm<sizeof(void *), sizeof(size_type)>::value) );
- BOOST_STATIC_CONSTANT(size_type, min_align =
- (::boost::integer::static_lcm< ::boost::alignment_of<void *>::value, ::boost::alignment_of<size_type>::value>::value) );
-
- //! \returns 0 if out-of-memory.
- //! Called if malloc/ordered_malloc needs to resize the free list.
- void * malloc_need_resize(); //! Called if malloc needs to resize the free list.
- void * ordered_malloc_need_resize(); //! Called if ordered_malloc needs to resize the free list.
-
- protected:
- details::PODptr<size_type> list; //!< List structure holding ordered blocks.
-
- simple_segregated_storage<size_type> & store()
- { //! \returns pointer to store.
- return *this;
- }
- const simple_segregated_storage<size_type> & store() const
- { //! \returns pointer to store.
- return *this;
- }
- const size_type requested_size;
- size_type next_size;
- size_type start_size;
- size_type max_size;
-
- //! finds which POD in the list 'chunk' was allocated from.
- details::PODptr<size_type> find_POD(void * const chunk) const;
-
- // is_from() tests a chunk to determine if it belongs in a block.
- static bool is_from(void * const chunk, char * const i,
- const size_type sizeof_i)
- { //! \param chunk chunk to check if is from this pool.
- //! \param i memory chunk at i with element sizeof_i.
- //! \param sizeof_i element size (size of the chunk area of that block, not the total size of that block).
- //! \returns true if chunk was allocated or may be returned.
- //! as the result of a future allocation.
- //!
- //! Returns false if chunk was allocated from some other pool,
- //! or may be returned as the result of a future allocation from some other pool.
- //! Otherwise, the return value is meaningless.
- //!
- //! Note that this function may not be used to reliably test random pointer values.
-
- // We use std::less_equal and std::less to test 'chunk'
- // against the array bounds because standard operators
- // may return unspecified results.
- // This is to ensure portability. The operators < <= > >= are only
- // defined for pointers to objects that are 1) in the same array, or
- // 2) subobjects of the same object [5.9/2].
- // The functor objects guarantee a total order for any pointer [20.3.3/8]
- std::less_equal<void *> lt_eq;
- std::less<void *> lt;
- return (lt_eq(i, chunk) && lt(chunk, i + sizeof_i));
- }
-
- size_type alloc_size() const
- { //! Calculated size of the memory chunks that will be allocated by this Pool.
- //! \returns allocated size.
- // For alignment reasons, this used to be defined to be lcm(requested_size, sizeof(void *), sizeof(size_type)),
- // but is now more parsimonious: just rounding up to the minimum required alignment of our housekeeping data
- // when required. This works provided all alignments are powers of two.
- size_type s = (std::max)(requested_size, min_alloc_size);
- size_type rem = s % min_align;
- if(rem)
- s += min_align - rem;
- BOOST_ASSERT(s >= min_alloc_size);
- BOOST_ASSERT(s % min_align == 0);
- return s;
- }
-
- static void * & nextof(void * const ptr)
- { //! \returns Pointer dereferenced.
- //! (Provided and used for the sake of code readability :)
- return *(static_cast<void **>(ptr));
- }
-
- public:
- // pre: npartition_size != 0 && nnext_size != 0
- explicit pool(const size_type nrequested_size,
- const size_type nnext_size = 32,
- const size_type nmax_size = 0)
- :
- list(0, 0), requested_size(nrequested_size), next_size(nnext_size), start_size(nnext_size),max_size(nmax_size)
- { //! Constructs a new empty Pool that can be used to allocate chunks of size RequestedSize.
- //! \param nrequested_size Requested chunk size
- //! \param nnext_size parameter is of type size_type,
- //! is the number of chunks to request from the system
- //! the first time that object needs to allocate system memory.
- //! The default is 32. This parameter may not be 0.
- //! \param nmax_size is the maximum number of chunks to allocate in one block.
- }
-
- ~pool()
- { //! Destructs the Pool, freeing its list of memory blocks.
- purge_memory();
- }
-
- // Releases memory blocks that don't have chunks allocated
- // pre: lists are ordered
- // Returns true if memory was actually deallocated
- bool release_memory();
-
- // Releases *all* memory blocks, even if chunks are still allocated
- // Returns true if memory was actually deallocated
- bool purge_memory();
-
- size_type get_next_size() const
- { //! Number of chunks to request from the system the next time that object needs to allocate system memory. This value should never be 0.
- //! \returns next_size;
- return next_size;
- }
- void set_next_size(const size_type nnext_size)
- { //! Set number of chunks to request from the system the next time that object needs to allocate system memory. This value should never be set to 0.
- //! \returns nnext_size.
- next_size = start_size = nnext_size;
- }
- size_type get_max_size() const
- { //! \returns max_size.
- return max_size;
- }
- void set_max_size(const size_type nmax_size)
- { //! Set max_size.
- max_size = nmax_size;
- }
- size_type get_requested_size() const
- { //! \returns the requested size passed into the constructor.
- //! (This value will not change during the lifetime of a Pool object).
- return requested_size;
- }
-
- // Both malloc and ordered_malloc do a quick inlined check first for any
- // free chunks. Only if we need to get another memory block do we call
- // the non-inlined *_need_resize() functions.
- // Returns 0 if out-of-memory
- void * malloc BOOST_PREVENT_MACRO_SUBSTITUTION()
- { //! Allocates a chunk of memory. Searches in the list of memory blocks
- //! for a block that has a free chunk, and returns that free chunk if found.
- //! Otherwise, creates a new memory block, adds its free list to pool's free list,
- //! \returns a free chunk from that block.
- //! If a new memory block cannot be allocated, returns 0. Amortized O(1).
- // Look for a non-empty storage
- if (!store().empty())
- return (store().malloc)();
- return malloc_need_resize();
- }
-
- void * ordered_malloc()
- { //! Same as malloc, only merges the free lists, to preserve order. Amortized O(1).
- //! \returns a free chunk from that block.
- //! If a new memory block cannot be allocated, returns 0. Amortized O(1).
- // Look for a non-empty storage
- if (!store().empty())
- return (store().malloc)();
- return ordered_malloc_need_resize();
- }
-
- // Returns 0 if out-of-memory
- // Allocate a contiguous section of n chunks
- void * ordered_malloc(size_type n);
- //! Same as malloc, only allocates enough contiguous chunks to cover n * requested_size bytes. Amortized O(n).
- //! \returns a free chunk from that block.
- //! If a new memory block cannot be allocated, returns 0. Amortized O(1).
-
- // pre: 'chunk' must have been previously
- // returned by *this.malloc().
- void free BOOST_PREVENT_MACRO_SUBSTITUTION(void * const chunk)
- { //! Deallocates a chunk of memory. Note that chunk may not be 0. O(1).
- //!
- //! Chunk must have been previously returned by t.malloc() or t.ordered_malloc().
- //! Assumes that chunk actually refers to a block of chunks
- //! spanning n * partition_sz bytes.
- //! deallocates each chunk in that block.
- //! Note that chunk may not be 0. O(n).
- (store().free)(chunk);
- }
-
- // pre: 'chunk' must have been previously
- // returned by *this.malloc().
- void ordered_free(void * const chunk)
- { //! Same as above, but is order-preserving.
- //!
- //! Note that chunk may not be 0. O(N) with respect to the size of the free list.
- //! chunk must have been previously returned by t.malloc() or t.ordered_malloc().
- store().ordered_free(chunk);
- }
-
- // pre: 'chunk' must have been previously
- // returned by *this.malloc(n).
- void free BOOST_PREVENT_MACRO_SUBSTITUTION(void * const chunks, const size_type n)
- { //! Assumes that chunk actually refers to a block of chunks.
- //!
- //! chunk must have been previously returned by t.ordered_malloc(n)
- //! spanning n * partition_sz bytes.
- //! Deallocates each chunk in that block.
- //! Note that chunk may not be 0. O(n).
- const size_type partition_size = alloc_size();
- const size_type total_req_size = n * requested_size;
- const size_type num_chunks = total_req_size / partition_size +
- ((total_req_size % partition_size) ? true : false);
-
- store().free_n(chunks, num_chunks, partition_size);
- }
-
- // pre: 'chunk' must have been previously
- // returned by *this.malloc(n).
- void ordered_free(void * const chunks, const size_type n)
- { //! Assumes that chunk actually refers to a block of chunks spanning n * partition_sz bytes;
- //! deallocates each chunk in that block.
- //!
- //! Note that chunk may not be 0. Order-preserving. O(N + n) where N is the size of the free list.
- //! chunk must have been previously returned by t.malloc() or t.ordered_malloc().
-
- const size_type partition_size = alloc_size();
- const size_type total_req_size = n * requested_size;
- const size_type num_chunks = total_req_size / partition_size +
- ((total_req_size % partition_size) ? true : false);
-
- store().ordered_free_n(chunks, num_chunks, partition_size);
- }
-
- // is_from() tests a chunk to determine if it was allocated from *this
- bool is_from(void * const chunk) const
- { //! \returns Returns true if chunk was allocated from u or
- //! may be returned as the result of a future allocation from u.
- //! Returns false if chunk was allocated from some other pool or
- //! may be returned as the result of a future allocation from some other pool.
- //! Otherwise, the return value is meaningless.
- //! Note that this function may not be used to reliably test random pointer values.
- return (find_POD(chunk).valid());
- }
-};
-
-#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
-template <typename UserAllocator>
-typename pool<UserAllocator>::size_type const pool<UserAllocator>::min_alloc_size;
-template <typename UserAllocator>
-typename pool<UserAllocator>::size_type const pool<UserAllocator>::min_align;
-#endif
-
-template <typename UserAllocator>
-bool pool<UserAllocator>::release_memory()
-{ //! pool must be ordered. Frees every memory block that doesn't have any allocated chunks.
- //! \returns true if at least one memory block was freed.
-
- // ret is the return value: it will be set to true when we actually call
- // UserAllocator::free(..)
- bool ret = false;
-
- // This is a current & previous iterator pair over the memory block list
- details::PODptr<size_type> ptr = list;
- details::PODptr<size_type> prev;
-
- // This is a current & previous iterator pair over the free memory chunk list
- // Note that "prev_free" in this case does NOT point to the previous memory
- // chunk in the free list, but rather the last free memory chunk before the
- // current block.
- void * free_p = this->first;
- void * prev_free_p = 0;
-
- const size_type partition_size = alloc_size();
-
- // Search through all the all the allocated memory blocks
- while (ptr.valid())
- {
- // At this point:
- // ptr points to a valid memory block
- // free_p points to either:
- // 0 if there are no more free chunks
- // the first free chunk in this or some next memory block
- // prev_free_p points to either:
- // the last free chunk in some previous memory block
- // 0 if there is no such free chunk
- // prev is either:
- // the PODptr whose next() is ptr
- // !valid() if there is no such PODptr
-
- // If there are no more free memory chunks, then every remaining
- // block is allocated out to its fullest capacity, and we can't
- // release any more memory
- if (free_p == 0)
- break;
-
- // We have to check all the chunks. If they are *all* free (i.e., present
- // in the free list), then we can free the block.
- bool all_chunks_free = true;
-
- // Iterate 'i' through all chunks in the memory block
- // if free starts in the memory block, be careful to keep it there
- void * saved_free = free_p;
- for (char * i = ptr.begin(); i != ptr.end(); i += partition_size)
- {
- // If this chunk is not free
- if (i != free_p)
- {
- // We won't be able to free this block
- all_chunks_free = false;
-
- // free_p might have travelled outside ptr
- free_p = saved_free;
- // Abort searching the chunks; we won't be able to free this
- // block because a chunk is not free.
- break;
- }
-
- // We do not increment prev_free_p because we are in the same block
- free_p = nextof(free_p);
- }
-
- // post: if the memory block has any chunks, free_p points to one of them
- // otherwise, our assertions above are still valid
-
- const details::PODptr<size_type> next = ptr.next();
-
- if (!all_chunks_free)
- {
- if (is_from(free_p, ptr.begin(), ptr.element_size()))
- {
- std::less<void *> lt;
- void * const end = ptr.end();
- do
- {
- prev_free_p = free_p;
- free_p = nextof(free_p);
- } while (free_p && lt(free_p, end));
- }
- // This invariant is now restored:
- // free_p points to the first free chunk in some next memory block, or
- // 0 if there is no such chunk.
- // prev_free_p points to the last free chunk in this memory block.
-
- // We are just about to advance ptr. Maintain the invariant:
- // prev is the PODptr whose next() is ptr, or !valid()
- // if there is no such PODptr
- prev = ptr;
- }
- else
- {
- // All chunks from this block are free
-
- // Remove block from list
- if (prev.valid())
- prev.next(next);
- else
- list = next;
-
- // Remove all entries in the free list from this block
- if (prev_free_p != 0)
- nextof(prev_free_p) = free_p;
- else
- this->first = free_p;
-
- // And release memory
- (UserAllocator::free)(ptr.begin());
- ret = true;
- }
-
- // Increment ptr
- ptr = next;
- }
-
- next_size = start_size;
- return ret;
-}
-
-template <typename UserAllocator>
-bool pool<UserAllocator>::purge_memory()
-{ //! pool must be ordered.
- //! Frees every memory block.
- //!
- //! This function invalidates any pointers previously returned
- //! by allocation functions of t.
- //! \returns true if at least one memory block was freed.
-
- details::PODptr<size_type> iter = list;
-
- if (!iter.valid())
- return false;
-
- do
- {
- // hold "next" pointer
- const details::PODptr<size_type> next = iter.next();
-
- // delete the storage
- (UserAllocator::free)(iter.begin());
-
- // increment iter
- iter = next;
- } while (iter.valid());
-
- list.invalidate();
- this->first = 0;
- next_size = start_size;
-
- return true;
-}
-
-template <typename UserAllocator>
-void * pool<UserAllocator>::malloc_need_resize()
-{ //! No memory in any of our storages; make a new storage,
- //! Allocates chunk in newly malloc aftert resize.
- //! \returns pointer to chunk.
- size_type partition_size = alloc_size();
- size_type POD_size = static_cast<size_type>(next_size * partition_size +
- integer::static_lcm<sizeof(size_type), sizeof(void *)>::value + sizeof(size_type));
- char * ptr = (UserAllocator::malloc)(POD_size);
- if (ptr == 0)
- {
- if(next_size > 4)
- {
- next_size >>= 1;
- partition_size = alloc_size();
- POD_size = static_cast<size_type>(next_size * partition_size +
- integer::static_lcm<sizeof(size_type), sizeof(void *)>::value + sizeof(size_type));
- ptr = (UserAllocator::malloc)(POD_size);
- }
- if(ptr == 0)
- return 0;
- }
- const details::PODptr<size_type> node(ptr, POD_size);
-
- BOOST_USING_STD_MIN();
- if(!max_size)
- next_size <<= 1;
- else if( next_size*partition_size/requested_size < max_size)
- next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size);
-
- // initialize it,
- store().add_block(node.begin(), node.element_size(), partition_size);
-
- // insert it into the list,
- node.next(list);
- list = node;
-
- // and return a chunk from it.
- return (store().malloc)();
-}
-
-template <typename UserAllocator>
-void * pool<UserAllocator>::ordered_malloc_need_resize()
-{ //! No memory in any of our storages; make a new storage,
- //! \returns pointer to new chunk.
- size_type partition_size = alloc_size();
- size_type POD_size = static_cast<size_type>(next_size * partition_size +
- integer::static_lcm<sizeof(size_type), sizeof(void *)>::value + sizeof(size_type));
- char * ptr = (UserAllocator::malloc)(POD_size);
- if (ptr == 0)
- {
- if(next_size > 4)
- {
- next_size >>= 1;
- partition_size = alloc_size();
- POD_size = static_cast<size_type>(next_size * partition_size +
- integer::static_lcm<sizeof(size_type), sizeof(void *)>::value + sizeof(size_type));
- ptr = (UserAllocator::malloc)(POD_size);
- }
- if(ptr == 0)
- return 0;
- }
- const details::PODptr<size_type> node(ptr, POD_size);
-
- BOOST_USING_STD_MIN();
- if(!max_size)
- next_size <<= 1;
- else if( next_size*partition_size/requested_size < max_size)
- next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size);
-
- // initialize it,
- // (we can use "add_block" here because we know that
- // the free list is empty, so we don't have to use
- // the slower ordered version)
- store().add_ordered_block(node.begin(), node.element_size(), partition_size);
-
- // insert it into the list,
- // handle border case
- if (!list.valid() || std::greater<void *>()(list.begin(), node.begin()))
- {
- node.next(list);
- list = node;
- }
- else
- {
- details::PODptr<size_type> prev = list;
-
- while (true)
- {
- // if we're about to hit the end or
- // if we've found where "node" goes
- if (prev.next_ptr() == 0
- || std::greater<void *>()(prev.next_ptr(), node.begin()))
- break;
-
- prev = prev.next();
- }
-
- node.next(prev.next());
- prev.next(node);
- }
- // and return a chunk from it.
- return (store().malloc)();
-}
-
-template <typename UserAllocator>
-void * pool<UserAllocator>::ordered_malloc(const size_type n)
-{ //! Gets address of a chunk n, allocating new memory if not already available.
- //! \returns Address of chunk n if allocated ok.
- //! \returns 0 if not enough memory for n chunks.
-
- const size_type partition_size = alloc_size();
- const size_type total_req_size = n * requested_size;
- const size_type num_chunks = total_req_size / partition_size +
- ((total_req_size % partition_size) ? true : false);
-
- void * ret = store().malloc_n(num_chunks, partition_size);
-
-#ifdef BOOST_POOL_INSTRUMENT
- std::cout << "Allocating " << n << " chunks from pool of size " << partition_size << std::endl;
-#endif
- if ((ret != 0) || (n == 0))
- return ret;
-
-#ifdef BOOST_POOL_INSTRUMENT
- std::cout << "Cache miss, allocating another chunk...\n";
-#endif
-
- // Not enough memory in our storages; make a new storage,
- BOOST_USING_STD_MAX();
- next_size = max BOOST_PREVENT_MACRO_SUBSTITUTION(next_size, num_chunks);
- size_type POD_size = static_cast<size_type>(next_size * partition_size +
- integer::static_lcm<sizeof(size_type), sizeof(void *)>::value + sizeof(size_type));
- char * ptr = (UserAllocator::malloc)(POD_size);
- if (ptr == 0)
- {
- if(num_chunks < next_size)
- {
- // Try again with just enough memory to do the job, or at least whatever we
- // allocated last time:
- next_size >>= 1;
- next_size = max BOOST_PREVENT_MACRO_SUBSTITUTION(next_size, num_chunks);
- POD_size = static_cast<size_type>(next_size * partition_size +
- integer::static_lcm<sizeof(size_type), sizeof(void *)>::value + sizeof(size_type));
- ptr = (UserAllocator::malloc)(POD_size);
- }
- if(ptr == 0)
- return 0;
- }
- const details::PODptr<size_type> node(ptr, POD_size);
-
- // Split up block so we can use what wasn't requested.
- if (next_size > num_chunks)
- store().add_ordered_block(node.begin() + num_chunks * partition_size,
- node.element_size() - num_chunks * partition_size, partition_size);
-
- BOOST_USING_STD_MIN();
- if(!max_size)
- next_size <<= 1;
- else if( next_size*partition_size/requested_size < max_size)
- next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size);
-
- // insert it into the list,
- // handle border case.
- if (!list.valid() || std::greater<void *>()(list.begin(), node.begin()))
- {
- node.next(list);
- list = node;
- }
- else
- {
- details::PODptr<size_type> prev = list;
-
- while (true)
- {
- // if we're about to hit the end, or if we've found where "node" goes.
- if (prev.next_ptr() == 0
- || std::greater<void *>()(prev.next_ptr(), node.begin()))
- break;
-
- prev = prev.next();
- }
-
- node.next(prev.next());
- prev.next(node);
- }
-
- // and return it.
- return node.begin();
-}
-
-template <typename UserAllocator>
-details::PODptr<typename pool<UserAllocator>::size_type>
-pool<UserAllocator>::find_POD(void * const chunk) const
-{ //! find which PODptr storage memory that this chunk is from.
- //! \returns the PODptr that holds this chunk.
- // Iterate down list to find which storage this chunk is from.
- details::PODptr<size_type> iter = list;
- while (iter.valid())
- {
- if (is_from(chunk, iter.begin(), iter.element_size()))
- return iter;
- iter = iter.next();
- }
-
- return iter;
-}
-
-#else // BOOST_POOL_VALGRIND
-
-template<typename UserAllocator>
-class pool
-{
-public:
- // types
- typedef UserAllocator user_allocator; // User allocator.
- typedef typename UserAllocator::size_type size_type; // An unsigned integral type that can represent the size of the largest object to be allocated.
- typedef typename UserAllocator::difference_type difference_type; // A signed integral type that can represent the difference of any two pointers.
-
- // construct/copy/destruct
- explicit pool(const size_type s, const size_type = 32, const size_type m = 0) : chunk_size(s), max_alloc_size(m) {}
- ~pool()
- {
- purge_memory();
- }
-
- bool release_memory()
- {
- bool ret = free_list.empty() ? false : true;
- for(std::set<void*>::iterator pos = free_list.begin(); pos != free_list.end(); ++pos)
- {
- (user_allocator::free)(static_cast<char*>(*pos));
- }
- free_list.clear();
- return ret;
- }
- bool purge_memory()
- {
- bool ret = free_list.empty() && used_list.empty() ? false : true;
- for(std::set<void*>::iterator pos = free_list.begin(); pos != free_list.end(); ++pos)
- {
- (user_allocator::free)(static_cast<char*>(*pos));
- }
- free_list.clear();
- for(std::set<void*>::iterator pos = used_list.begin(); pos != used_list.end(); ++pos)
- {
- (user_allocator::free)(static_cast<char*>(*pos));
- }
- used_list.clear();
- return ret;
- }
- size_type get_next_size() const
- {
- return 1;
- }
- void set_next_size(const size_type){}
- size_type get_max_size() const
- {
- return max_alloc_size;
- }
- void set_max_size(const size_type s)
- {
- max_alloc_size = s;
- }
- size_type get_requested_size() const
- {
- return chunk_size;
- }
- void * malloc BOOST_PREVENT_MACRO_SUBSTITUTION()
- {
- void* ret;
- if(free_list.empty())
- {
- ret = (user_allocator::malloc)(chunk_size);
- VALGRIND_MAKE_MEM_UNDEFINED(ret, chunk_size);
- }
- else
- {
- ret = *free_list.begin();
- free_list.erase(free_list.begin());
- VALGRIND_MAKE_MEM_UNDEFINED(ret, chunk_size);
- }
- used_list.insert(ret);
- return ret;
- }
- void * ordered_malloc()
- {
- return (this->malloc)();
- }
- void * ordered_malloc(size_type n)
- {
- if(max_alloc_size && (n > max_alloc_size))
- return 0;
- void* ret = (user_allocator::malloc)(chunk_size * n);
- used_list.insert(ret);
- return ret;
- }
- void free BOOST_PREVENT_MACRO_SUBSTITUTION(void *const chunk)
- {
- BOOST_ASSERT(used_list.count(chunk) == 1);
- BOOST_ASSERT(free_list.count(chunk) == 0);
- used_list.erase(chunk);
- free_list.insert(chunk);
- VALGRIND_MAKE_MEM_NOACCESS(chunk, chunk_size);
- }
- void ordered_free(void *const chunk)
- {
- return (this->free)(chunk);
- }
- void free BOOST_PREVENT_MACRO_SUBSTITUTION(void *const chunk, const size_type)
- {
- BOOST_ASSERT(used_list.count(chunk) == 1);
- BOOST_ASSERT(free_list.count(chunk) == 0);
- used_list.erase(chunk);
- (user_allocator::free)(static_cast<char*>(chunk));
- }
- void ordered_free(void *const chunk, const size_type n)
- {
- (this->free)(chunk, n);
- }
- bool is_from(void *const chunk) const
- {
- return used_list.count(chunk) || free_list.count(chunk);
- }
-
-protected:
- size_type chunk_size, max_alloc_size;
- std::set<void*> free_list, used_list;
-};
-
-#endif
-
-} // namespace boost
-
-#ifdef BOOST_MSVC
-#pragma warning(pop)
-#endif
-
-#endif // #ifdef BOOST_POOL_HPP
-
diff --git a/contrib/restricted/boost/boost/pool/pool_alloc.hpp b/contrib/restricted/boost/boost/pool/pool_alloc.hpp
deleted file mode 100644
index 4233ca66a6d..00000000000
--- a/contrib/restricted/boost/boost/pool/pool_alloc.hpp
+++ /dev/null
@@ -1,512 +0,0 @@
-// Copyright (C) 2000, 2001 Stephen Cleary
-// Copyright (C) 2010 Paul A. Bristow added Doxygen comments.
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org for updates, documentation, and revision history.
-
-#ifndef BOOST_POOL_ALLOC_HPP
-#define BOOST_POOL_ALLOC_HPP
-
-/*!
- \file
- \brief C++ Standard Library compatible pool-based allocators.
- \details This header provides two template types -
- \ref pool_allocator and \ref fast_pool_allocator -
- that can be used for fast and efficient memory allocation
- in conjunction with the C++ Standard Library containers.
-
- These types both satisfy the Standard Allocator requirements [20.1.5]
- and the additional requirements in [20.1.5/4],
- so they can be used with either Standard or user-supplied containers.
-
- In addition, the fast_pool_allocator also provides an additional allocation
- and an additional deallocation function:
-
-<table>
-<tr><th>Expression</th><th>Return Type</th><th>Semantic Equivalence<th></tr>
-<tr><td><tt>PoolAlloc::allocate()</tt></td><td><tt>T *</tt></td><td><tt>PoolAlloc::allocate(1)</tt></tr>
-<tr><td><tt>PoolAlloc::deallocate(p)</tt></td><td>void</tt></td><td><tt>PoolAlloc::deallocate(p, 1)</tt></tr>
-</table>
-
-The typedef user_allocator publishes the value of the UserAllocator template parameter.
-
-<b>Notes</b>
-
-If the allocation functions run out of memory, they will throw <tt>std::bad_alloc</tt>.
-
-The underlying Pool type used by the allocators is accessible through the Singleton Pool Interface.
-The identifying tag used for pool_allocator is pool_allocator_tag,
-and the tag used for fast_pool_allocator is fast_pool_allocator_tag.
-All template parameters of the allocators (including implementation-specific ones)
-determine the type of the underlying Pool,
-with the exception of the first parameter T, whose size is used instead.
-
-Since the size of T is used to determine the type of the underlying Pool,
-each allocator for different types of the same size will share the same underlying pool.
-The tag class prevents pools from being shared between pool_allocator and fast_pool_allocator.
-For example, on a system where
-<tt>sizeof(int) == sizeof(void *)</tt>, <tt>pool_allocator<int></tt> and <tt>pool_allocator<void *></tt>
-will both allocate/deallocate from/to the same pool.
-
-If there is only one thread running before main() starts and after main() ends,
-then both allocators are completely thread-safe.
-
-<b>Compiler and STL Notes</b>
-
-A number of common STL libraries contain bugs in their using of allocators.
-Specifically, they pass null pointers to the deallocate function,
-which is explicitly forbidden by the Standard [20.1.5 Table 32].
-PoolAlloc will work around these libraries if it detects them;
-currently, workarounds are in place for:
-Borland C++ (Builder and command-line compiler)
-with default (RogueWave) library, ver. 5 and earlier,
-STLport (with any compiler), ver. 4.0 and earlier.
-*/
-
-// std::numeric_limits
-#include <boost/limits.hpp>
-// new, std::bad_alloc
-#include <new>
-
-#include <boost/throw_exception.hpp>
-#include <boost/pool/poolfwd.hpp>
-
-// boost::singleton_pool
-#include <boost/pool/singleton_pool.hpp>
-
-#include <boost/detail/workaround.hpp>
-
-// C++11 features detection
-#include <boost/config.hpp>
-
-// std::forward
-#ifdef BOOST_HAS_VARIADIC_TMPL
-#include <utility>
-#endif
-
-#ifdef BOOST_POOL_INSTRUMENT
-#include <iostream>
-#include <iomanip>
-#endif
-
-// The following code will be put into Boost.Config in a later revision
-#if defined(_RWSTD_VER) || defined(__SGI_STL_PORT) || \
- BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
- #define BOOST_NO_PROPER_STL_DEALLOCATE
-#endif
-
-namespace boost {
-
-#ifdef BOOST_POOL_INSTRUMENT
-
-template <bool b>
-struct debug_info
-{
- static unsigned allocated;
-};
-
-template <bool b>
-unsigned debug_info<b>::allocated = 0;
-
-#endif
-
- //! Simple tag type used by pool_allocator as an argument to the
- //! underlying singleton_pool.
- struct pool_allocator_tag
-{
-};
-
-/*! \brief A C++ Standard Library conforming allocator, based on an underlying pool.
-
- Template parameters for pool_allocator are defined as follows:
-
- <b>T</b> Type of object to allocate/deallocate.
-
- <b>UserAllocator</B>. Defines the method that the underlying Pool will use to allocate memory from the system. See
- <a href="boost_pool/pool/pooling.html#boost_pool.pool.pooling.user_allocator">User Allocators</a> for details.
-
- <b>Mutex</b> Allows the user to determine the type of synchronization to be used on the underlying singleton_pool.
-
- <b>NextSize</b> The value of this parameter is passed to the underlying singleton_pool when it is created.
-
- <b>MaxSize</b> Limit on the maximum size used.
-
- \attention
- The underlying singleton_pool used by the this allocator
- constructs a pool instance that
- <b>is never freed</b>. This means that memory allocated
- by the allocator can be still used after main() has
- completed, but may mean that some memory checking programs
- will complain about leaks.
-
-
- */
-template <typename T,
- typename UserAllocator,
- typename Mutex,
- unsigned NextSize,
- unsigned MaxSize >
-class pool_allocator
-{
- public:
- typedef T value_type; //!< value_type of template parameter T.
- typedef UserAllocator user_allocator; //!< allocator that defines the method that the underlying Pool will use to allocate memory from the system.
- typedef Mutex mutex; //!< typedef mutex publishes the value of the template parameter Mutex.
- BOOST_STATIC_CONSTANT(unsigned, next_size = NextSize); //!< next_size publishes the values of the template parameter NextSize.
-
- typedef value_type * pointer; //!<
- typedef const value_type * const_pointer;
- typedef value_type & reference;
- typedef const value_type & const_reference;
- typedef typename pool<UserAllocator>::size_type size_type;
- typedef typename pool<UserAllocator>::difference_type difference_type;
-
- //! \brief Nested class rebind allows for transformation from
- //! pool_allocator<T> to pool_allocator<U>.
- //!
- //! Nested class rebind allows for transformation from
- //! pool_allocator<T> to pool_allocator<U> via the member
- //! typedef other.
- template <typename U>
- struct rebind
- { //
- typedef pool_allocator<U, UserAllocator, Mutex, NextSize, MaxSize> other;
- };
-
- public:
- pool_allocator()
- { /*! Results in default construction of the underlying singleton_pool IFF an
- instance of this allocator is constructed during global initialization (
- required to ensure construction of singleton_pool IFF an
- instance of this allocator is constructed during global
- initialization. See ticket #2359 for a complete explanation at
- http://svn.boost.org/trac/boost/ticket/2359) .
- */
- singleton_pool<pool_allocator_tag, sizeof(T), UserAllocator, Mutex,
- NextSize, MaxSize>::is_from(0);
- }
-
- // default copy constructor.
-
- // default assignment operator.
-
- // not explicit, mimicking std::allocator [20.4.1]
- template <typename U>
- pool_allocator(const pool_allocator<U, UserAllocator, Mutex, NextSize, MaxSize> &)
- { /*! Results in the default construction of the underlying singleton_pool, this
- is required to ensure construction of singleton_pool IFF an
- instance of this allocator is constructed during global
- initialization. See ticket #2359 for a complete explanation
- at http://svn.boost.org/trac/boost/ticket/2359 .
- */
- singleton_pool<pool_allocator_tag, sizeof(T), UserAllocator, Mutex,
- NextSize, MaxSize>::is_from(0);
- }
-
- // default destructor
-
- static pointer address(reference r)
- { return &r; }
- static const_pointer address(const_reference s)
- { return &s; }
- static size_type max_size()
- { return (std::numeric_limits<size_type>::max)(); }
-
-#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
- template <typename U, typename... Args>
- static void construct(U* ptr, Args&&... args)
- { new (ptr) U(std::forward<Args>(args)...); }
-#else
- static void construct(const pointer ptr, const value_type & t)
- { new (ptr) T(t); }
-#endif
-
- static void destroy(const pointer ptr)
- {
- ptr->~T();
- (void) ptr; // avoid unused variable warning.
- }
-
- bool operator==(const pool_allocator &) const
- { return true; }
- bool operator!=(const pool_allocator &) const
- { return false; }
-
- static pointer allocate(const size_type n)
- {
-#ifdef BOOST_POOL_INSTRUMENT
- debug_info<true>::allocated += n * sizeof(T);
- std::cout << "Allocating " << n << " * " << sizeof(T) << " bytes...\n"
- "Total allocated is now " << debug_info<true>::allocated << std::endl;
-#endif
- const pointer ret = static_cast<pointer>(
- singleton_pool<pool_allocator_tag, sizeof(T), UserAllocator, Mutex,
- NextSize, MaxSize>::ordered_malloc(n) );
- if ((ret == 0) && n)
- boost::throw_exception(std::bad_alloc());
- return ret;
- }
- static pointer allocate(const size_type n, const void * const)
- { //! allocate n bytes
- //! \param n bytes to allocate.
- //! \param unused.
- return allocate(n);
- }
- static void deallocate(const pointer ptr, const size_type n)
- { //! Deallocate n bytes from ptr
- //! \param ptr location to deallocate from.
- //! \param n number of bytes to deallocate.
-#ifdef BOOST_POOL_INSTRUMENT
- debug_info<true>::allocated -= n * sizeof(T);
- std::cout << "Deallocating " << n << " * " << sizeof(T) << " bytes...\n"
- "Total allocated is now " << debug_info<true>::allocated << std::endl;
-#endif
-#ifdef BOOST_NO_PROPER_STL_DEALLOCATE
- if (ptr == 0 || n == 0)
- return;
-#endif
- singleton_pool<pool_allocator_tag, sizeof(T), UserAllocator, Mutex,
- NextSize, MaxSize>::ordered_free(ptr, n);
- }
-};
-
-/*! \brief Specialization of pool_allocator<void>.
-
-Specialization of pool_allocator for type void: required by the standard to make this a conforming allocator type.
-*/
-template<
- typename UserAllocator,
- typename Mutex,
- unsigned NextSize,
- unsigned MaxSize>
-class pool_allocator<void, UserAllocator, Mutex, NextSize, MaxSize>
-{
-public:
- typedef void* pointer;
- typedef const void* const_pointer;
- typedef void value_type;
- //! \brief Nested class rebind allows for transformation from
- //! pool_allocator<T> to pool_allocator<U>.
- //!
- //! Nested class rebind allows for transformation from
- //! pool_allocator<T> to pool_allocator<U> via the member
- //! typedef other.
- template <class U>
- struct rebind
- {
- typedef pool_allocator<U, UserAllocator, Mutex, NextSize, MaxSize> other;
- };
-};
-
-//! Simple tag type used by fast_pool_allocator as a template parameter to the underlying singleton_pool.
-struct fast_pool_allocator_tag
-{
-};
-
- /*! \brief A C++ Standard Library conforming allocator geared towards allocating single chunks.
-
- While class template <tt>pool_allocator</tt> is a more general-purpose solution geared towards
- efficiently servicing requests for any number of contiguous chunks,
- <tt>fast_pool_allocator</tt> is also a general-purpose solution,
- but is geared towards efficiently servicing requests for one chunk at a time;
- it will work for contiguous chunks, but not as well as <tt>pool_allocator</tt>.
-
- If you are seriously concerned about performance,
- use <tt>fast_pool_allocator</tt> when dealing with containers such as <tt>std::list</tt>,
- and use <tt>pool_allocator</tt> when dealing with containers such as <tt>std::vector</tt>.
-
- The template parameters are defined as follows:
-
- <b>T</b> Type of object to allocate/deallocate.
-
- <b>UserAllocator</b>. Defines the method that the underlying Pool will use to allocate memory from the system.
- See <a href="boost_pool/pool/pooling.html#boost_pool.pool.pooling.user_allocator">User Allocators</a> for details.
-
- <b>Mutex</b> Allows the user to determine the type of synchronization to be used on the underlying <tt>singleton_pool</tt>.
-
- <b>NextSize</b> The value of this parameter is passed to the underlying Pool when it is created.
-
- <b>MaxSize</b> Limit on the maximum size used.
-
- \attention
- The underlying singleton_pool used by the this allocator
- constructs a pool instance that
- <b>is never freed</b>. This means that memory allocated
- by the allocator can be still used after main() has
- completed, but may mean that some memory checking programs
- will complain about leaks.
-
- */
-
-template <typename T,
- typename UserAllocator,
- typename Mutex,
- unsigned NextSize,
- unsigned MaxSize >
-class fast_pool_allocator
-{
- public:
- typedef T value_type;
- typedef UserAllocator user_allocator;
- typedef Mutex mutex;
- BOOST_STATIC_CONSTANT(unsigned, next_size = NextSize);
-
- typedef value_type * pointer;
- typedef const value_type * const_pointer;
- typedef value_type & reference;
- typedef const value_type & const_reference;
- typedef typename pool<UserAllocator>::size_type size_type;
- typedef typename pool<UserAllocator>::difference_type difference_type;
-
- //! \brief Nested class rebind allows for transformation from
- //! fast_pool_allocator<T> to fast_pool_allocator<U>.
- //!
- //! Nested class rebind allows for transformation from
- //! fast_pool_allocator<T> to fast_pool_allocator<U> via the member
- //! typedef other.
- template <typename U>
- struct rebind
- {
- typedef fast_pool_allocator<U, UserAllocator, Mutex, NextSize, MaxSize> other;
- };
-
- public:
- fast_pool_allocator()
- {
- //! Ensures construction of the underlying singleton_pool IFF an
- //! instance of this allocator is constructed during global
- //! initialization. See ticket #2359 for a complete explanation
- //! at http://svn.boost.org/trac/boost/ticket/2359 .
- singleton_pool<fast_pool_allocator_tag, sizeof(T),
- UserAllocator, Mutex, NextSize, MaxSize>::is_from(0);
- }
-
- // Default copy constructor used.
-
- // Default assignment operator used.
-
- // Not explicit, mimicking std::allocator [20.4.1]
- template <typename U>
- fast_pool_allocator(
- const fast_pool_allocator<U, UserAllocator, Mutex, NextSize, MaxSize> &)
- {
- //! Ensures construction of the underlying singleton_pool IFF an
- //! instance of this allocator is constructed during global
- //! initialization. See ticket #2359 for a complete explanation
- //! at http://svn.boost.org/trac/boost/ticket/2359 .
- singleton_pool<fast_pool_allocator_tag, sizeof(T),
- UserAllocator, Mutex, NextSize, MaxSize>::is_from(0);
- }
-
- // Default destructor used.
-
- static pointer address(reference r)
- {
- return &r;
- }
- static const_pointer address(const_reference s)
- { return &s; }
- static size_type max_size()
- { return (std::numeric_limits<size_type>::max)(); }
-
-#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
- template <typename U, typename... Args>
- void construct(U* ptr, Args&&... args)
- { new (ptr) U(std::forward<Args>(args)...); }
-#else
- void construct(const pointer ptr, const value_type & t)
- { new (ptr) T(t); }
-#endif
-
- void destroy(const pointer ptr)
- { //! Destroy ptr using destructor.
- ptr->~T();
- (void) ptr; // Avoid unused variable warning.
- }
-
- bool operator==(const fast_pool_allocator &) const
- { return true; }
- bool operator!=(const fast_pool_allocator &) const
- { return false; }
-
- static pointer allocate(const size_type n)
- {
- const pointer ret = (n == 1) ?
- static_cast<pointer>(
- (singleton_pool<fast_pool_allocator_tag, sizeof(T),
- UserAllocator, Mutex, NextSize, MaxSize>::malloc)() ) :
- static_cast<pointer>(
- singleton_pool<fast_pool_allocator_tag, sizeof(T),
- UserAllocator, Mutex, NextSize, MaxSize>::ordered_malloc(n) );
- if (ret == 0)
- boost::throw_exception(std::bad_alloc());
- return ret;
- }
- static pointer allocate(const size_type n, const void * const)
- { //! Allocate memory .
- return allocate(n);
- }
- static pointer allocate()
- { //! Allocate memory.
- const pointer ret = static_cast<pointer>(
- (singleton_pool<fast_pool_allocator_tag, sizeof(T),
- UserAllocator, Mutex, NextSize, MaxSize>::malloc)() );
- if (ret == 0)
- boost::throw_exception(std::bad_alloc());
- return ret;
- }
- static void deallocate(const pointer ptr, const size_type n)
- { //! Deallocate memory.
-
-#ifdef BOOST_NO_PROPER_STL_DEALLOCATE
- if (ptr == 0 || n == 0)
- return;
-#endif
- if (n == 1)
- (singleton_pool<fast_pool_allocator_tag, sizeof(T),
- UserAllocator, Mutex, NextSize, MaxSize>::free)(ptr);
- else
- (singleton_pool<fast_pool_allocator_tag, sizeof(T),
- UserAllocator, Mutex, NextSize, MaxSize>::free)(ptr, n);
- }
- static void deallocate(const pointer ptr)
- { //! deallocate/free
- (singleton_pool<fast_pool_allocator_tag, sizeof(T),
- UserAllocator, Mutex, NextSize, MaxSize>::free)(ptr);
- }
-};
-
-/*! \brief Specialization of fast_pool_allocator<void>.
-
-Specialization of fast_pool_allocator<void> required to make the allocator standard-conforming.
-*/
-template<
- typename UserAllocator,
- typename Mutex,
- unsigned NextSize,
- unsigned MaxSize >
-class fast_pool_allocator<void, UserAllocator, Mutex, NextSize, MaxSize>
-{
-public:
- typedef void* pointer;
- typedef const void* const_pointer;
- typedef void value_type;
-
- //! \brief Nested class rebind allows for transformation from
- //! fast_pool_allocator<T> to fast_pool_allocator<U>.
- //!
- //! Nested class rebind allows for transformation from
- //! fast_pool_allocator<T> to fast_pool_allocator<U> via the member
- //! typedef other.
- template <class U> struct rebind
- {
- typedef fast_pool_allocator<U, UserAllocator, Mutex, NextSize, MaxSize> other;
- };
-};
-
-} // namespace boost
-
-#endif
diff --git a/contrib/restricted/boost/boost/pool/poolfwd.hpp b/contrib/restricted/boost/boost/pool/poolfwd.hpp
deleted file mode 100644
index 0f330fc79bc..00000000000
--- a/contrib/restricted/boost/boost/pool/poolfwd.hpp
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright (C) 2000, 2001 Stephen Cleary
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org for updates, documentation, and revision history.
-
-#ifndef BOOST_POOLFWD_HPP
-#define BOOST_POOLFWD_HPP
-
-/*!
- \file
- \brief Forward declarations of all public (non-implemention) classes.
-*/
-
-
-#include <boost/config.hpp> // for workarounds
-
-// std::size_t
-#include <cstddef>
-
-// boost::details::pool::default_mutex
-#include <boost/pool/detail/mutex.hpp>
-
-namespace boost {
-
-//
-// Location: <boost/pool/simple_segregated_storage.hpp>
-//
-template <typename SizeType = std::size_t>
-class simple_segregated_storage;
-
-//
-// Location: <boost/pool/pool.hpp>
-//
-struct default_user_allocator_new_delete;
-struct default_user_allocator_malloc_free;
-
-template <typename UserAllocator = default_user_allocator_new_delete>
-class pool;
-
-//
-// Location: <boost/pool/object_pool.hpp>
-//
-template <typename T, typename UserAllocator = default_user_allocator_new_delete>
-class object_pool;
-
-//
-// Location: <boost/pool/singleton_pool.hpp>
-//
-template <typename Tag, unsigned RequestedSize,
- typename UserAllocator = default_user_allocator_new_delete,
- typename Mutex = details::pool::default_mutex,
- unsigned NextSize = 32,
- unsigned MaxSize = 0>
-class singleton_pool;
-
-//
-// Location: <boost/pool/pool_alloc.hpp>
-//
-struct pool_allocator_tag;
-
-template <typename T,
- typename UserAllocator = default_user_allocator_new_delete,
- typename Mutex = details::pool::default_mutex,
- unsigned NextSize = 32,
- unsigned MaxSize = 0>
-class pool_allocator;
-
-struct fast_pool_allocator_tag;
-
-template <typename T,
- typename UserAllocator = default_user_allocator_new_delete,
- typename Mutex = details::pool::default_mutex,
- unsigned NextSize = 32,
- unsigned MaxSize = 0>
-class fast_pool_allocator;
-
-} // namespace boost
-
-#endif
diff --git a/contrib/restricted/boost/boost/pool/simple_segregated_storage.hpp b/contrib/restricted/boost/boost/pool/simple_segregated_storage.hpp
deleted file mode 100644
index fffd4ee6635..00000000000
--- a/contrib/restricted/boost/boost/pool/simple_segregated_storage.hpp
+++ /dev/null
@@ -1,377 +0,0 @@
-// Copyright (C) 2000, 2001 Stephen Cleary
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org for updates, documentation, and revision history.
-
-#ifndef BOOST_SIMPLE_SEGREGATED_STORAGE_HPP
-#define BOOST_SIMPLE_SEGREGATED_STORAGE_HPP
-
-/*!
- \file
- \brief Simple Segregated Storage.
- \details A simple segregated storage implementation:
- simple segregated storage is the basic idea behind the Boost Pool library.
- Simple segregated storage is the simplest, and probably the fastest,
- memory allocation/deallocation algorithm.
- It begins by partitioning a memory block into fixed-size chunks.
- Where the block comes from is not important until implementation time.
- A Pool is some object that uses Simple Segregated Storage in this fashion.
-*/
-
-// std::greater
-#include <functional>
-
-#include <boost/pool/poolfwd.hpp>
-
-#ifdef BOOST_MSVC
-#pragma warning(push)
-#pragma warning(disable:4127) // Conditional expression is constant
-#endif
-
-#ifdef BOOST_POOL_VALIDATE
-# define BOOST_POOL_VALIDATE_INTERNALS validate();
-#else
-# define BOOST_POOL_VALIDATE_INTERNALS
-#endif
-
-namespace boost {
-
-/*!
-
-\brief Simple Segregated Storage is the simplest, and probably the fastest,
-memory allocation/deallocation algorithm. It is responsible for
-partitioning a memory block into fixed-size chunks: where the block comes from
-is determined by the client of the class.
-
-\details Template class simple_segregated_storage controls access to a free list of memory chunks.
-Please note that this is a very simple class, with preconditions on almost all its functions. It is intended to
-be the fastest and smallest possible quick memory allocator - e.g., something to use in embedded systems.
-This class delegates many difficult preconditions to the user (i.e., alignment issues).
-
-An object of type simple_segregated_storage<SizeType> is empty if its free list is empty.
-If it is not empty, then it is ordered if its free list is ordered. A free list is ordered if repeated calls
-to <tt>malloc()</tt> will result in a constantly-increasing sequence of values, as determined by <tt>std::less<void *></tt>.
-A member function is <i>order-preserving</i> if the free list maintains its order orientation (that is, an
-ordered free list is still ordered after the member function call).
-
-*/
-template <typename SizeType>
-class simple_segregated_storage
-{
- public:
- typedef SizeType size_type;
-
- private:
- simple_segregated_storage(const simple_segregated_storage &);
- void operator=(const simple_segregated_storage &);
-
- static void * try_malloc_n(void * & start, size_type n,
- size_type partition_size);
-
- protected:
- void * first; /*!< This data member is the free list.
- It points to the first chunk in the free list,
- or is equal to 0 if the free list is empty.
- */
-
- void * find_prev(void * ptr);
-
- // for the sake of code readability :)
- static void * & nextof(void * const ptr)
- { //! The return value is just *ptr cast to the appropriate type. ptr must not be 0. (For the sake of code readability :)
- //! As an example, let us assume that we want to truncate the free list after the first chunk.
- //! That is, we want to set *first to 0; this will result in a free list with only one entry.
- //! The normal way to do this is to first cast first to a pointer to a pointer to void,
- //! and then dereference and assign (*static_cast<void **>(first) = 0;).
- //! This can be done more easily through the use of this convenience function (nextof(first) = 0;).
- //! \returns dereferenced pointer.
- return *(static_cast<void **>(ptr));
- }
-
- public:
- // Post: empty()
- simple_segregated_storage()
- :first(0)
- { //! Construct empty storage area.
- //! \post empty()
- }
-
- static void * segregate(void * block,
- size_type nsz, size_type npartition_sz,
- void * end = 0);
-
- // Same preconditions as 'segregate'
- // Post: !empty()
- void add_block(void * const block,
- const size_type nsz, const size_type npartition_sz)
- { //! Add block
- //! Segregate this block and merge its free list into the
- //! free list referred to by "first".
- //! \pre Same as segregate.
- //! \post !empty()
- BOOST_POOL_VALIDATE_INTERNALS
- first = segregate(block, nsz, npartition_sz, first);
- BOOST_POOL_VALIDATE_INTERNALS
- }
-
- // Same preconditions as 'segregate'
- // Post: !empty()
- void add_ordered_block(void * const block,
- const size_type nsz, const size_type npartition_sz)
- { //! add block (ordered into list)
- //! This (slower) version of add_block segregates the
- //! block and merges its free list into our free list
- //! in the proper order.
- BOOST_POOL_VALIDATE_INTERNALS
- // Find where "block" would go in the free list
- void * const loc = find_prev(block);
-
- // Place either at beginning or in middle/end
- if (loc == 0)
- add_block(block, nsz, npartition_sz);
- else
- nextof(loc) = segregate(block, nsz, npartition_sz, nextof(loc));
- BOOST_POOL_VALIDATE_INTERNALS
- }
-
- // default destructor.
-
- bool empty() const
- { //! \returns true only if simple_segregated_storage is empty.
- return (first == 0);
- }
-
- void * malloc BOOST_PREVENT_MACRO_SUBSTITUTION()
- { //! Create a chunk.
- //! \pre !empty()
- //! Increment the "first" pointer to point to the next chunk.
- BOOST_POOL_VALIDATE_INTERNALS
- void * const ret = first;
-
- // Increment the "first" pointer to point to the next chunk.
- first = nextof(first);
- BOOST_POOL_VALIDATE_INTERNALS
- return ret;
- }
-
- void free BOOST_PREVENT_MACRO_SUBSTITUTION(void * const chunk)
- { //! Free a chunk.
- //! \pre chunk was previously returned from a malloc() referring to the same free list.
- //! \post !empty()
- BOOST_POOL_VALIDATE_INTERNALS
- nextof(chunk) = first;
- first = chunk;
- BOOST_POOL_VALIDATE_INTERNALS
- }
-
- void ordered_free(void * const chunk)
- { //! This (slower) implementation of 'free' places the memory
- //! back in the list in its proper order.
- //! \pre chunk was previously returned from a malloc() referring to the same free list
- //! \post !empty().
-
- // Find where "chunk" goes in the free list
- BOOST_POOL_VALIDATE_INTERNALS
- void * const loc = find_prev(chunk);
-
- // Place either at beginning or in middle/end.
- if (loc == 0)
- (free)(chunk);
- else
- {
- nextof(chunk) = nextof(loc);
- nextof(loc) = chunk;
- }
- BOOST_POOL_VALIDATE_INTERNALS
- }
-
- void * malloc_n(size_type n, size_type partition_size);
-
- //! \pre chunks was previously allocated from *this with the same
- //! values for n and partition_size.
- //! \post !empty()
- //! \note If you're allocating/deallocating n a lot, you should
- //! be using an ordered pool.
- void free_n(void * const chunks, const size_type n,
- const size_type partition_size)
- {
- BOOST_POOL_VALIDATE_INTERNALS
- if(n != 0)
- add_block(chunks, n * partition_size, partition_size);
- BOOST_POOL_VALIDATE_INTERNALS
- }
-
- // pre: chunks was previously allocated from *this with the same
- // values for n and partition_size.
- // post: !empty()
- void ordered_free_n(void * const chunks, const size_type n,
- const size_type partition_size)
- { //! Free n chunks from order list.
- //! \pre chunks was previously allocated from *this with the same
- //! values for n and partition_size.
-
- //! \pre n should not be zero (n == 0 has no effect).
- BOOST_POOL_VALIDATE_INTERNALS
- if(n != 0)
- add_ordered_block(chunks, n * partition_size, partition_size);
- BOOST_POOL_VALIDATE_INTERNALS
- }
-#ifdef BOOST_POOL_VALIDATE
- void validate()
- {
- int index = 0;
- void* old = 0;
- void* ptr = first;
- while(ptr)
- {
- void* pt = nextof(ptr); // trigger possible segfault *before* we update variables
- ++index;
- old = ptr;
- ptr = nextof(ptr);
- }
- }
-#endif
-};
-
-//! Traverses the free list referred to by "first",
-//! and returns the iterator previous to where
-//! "ptr" would go if it was in the free list.
-//! Returns 0 if "ptr" would go at the beginning
-//! of the free list (i.e., before "first").
-
-//! \note Note that this function finds the location previous to where ptr would go
-//! if it was in the free list.
-//! It does not find the entry in the free list before ptr
-//! (unless ptr is already in the free list).
-//! Specifically, find_prev(0) will return 0,
-//! not the last entry in the free list.
-//! \returns location previous to where ptr would go if it was in the free list.
-template <typename SizeType>
-void * simple_segregated_storage<SizeType>::find_prev(void * const ptr)
-{
- // Handle border case.
- if (first == 0 || std::greater<void *>()(first, ptr))
- return 0;
-
- void * iter = first;
- while (true)
- {
- // if we're about to hit the end, or if we've found where "ptr" goes.
- if (nextof(iter) == 0 || std::greater<void *>()(nextof(iter), ptr))
- return iter;
-
- iter = nextof(iter);
- }
-}
-
-//! Segregate block into chunks.
-//! \pre npartition_sz >= sizeof(void *)
-//! \pre npartition_sz = sizeof(void *) * i, for some integer i
-//! \pre nsz >= npartition_sz
-//! \pre Block is properly aligned for an array of object of
-//! size npartition_sz and array of void *.
-//! The requirements above guarantee that any pointer to a chunk
-//! (which is a pointer to an element in an array of npartition_sz)
-//! may be cast to void **.
-template <typename SizeType>
-void * simple_segregated_storage<SizeType>::segregate(
- void * const block,
- const size_type sz,
- const size_type partition_sz,
- void * const end)
-{
- // Get pointer to last valid chunk, preventing overflow on size calculations
- // The division followed by the multiplication just makes sure that
- // old == block + partition_sz * i, for some integer i, even if the
- // block size (sz) is not a multiple of the partition size.
- char * old = static_cast<char *>(block)
- + ((sz - partition_sz) / partition_sz) * partition_sz;
-
- // Set it to point to the end
- nextof(old) = end;
-
- // Handle border case where sz == partition_sz (i.e., we're handling an array
- // of 1 element)
- if (old == block)
- return block;
-
- // Iterate backwards, building a singly-linked list of pointers
- for (char * iter = old - partition_sz; iter != block;
- old = iter, iter -= partition_sz)
- nextof(iter) = old;
-
- // Point the first pointer, too
- nextof(block) = old;
-
- return block;
-}
-
-//! \pre (n > 0), (start != 0), (nextof(start) != 0)
-//! \post (start != 0)
-//! The function attempts to find n contiguous chunks
-//! of size partition_size in the free list, starting at start.
-//! If it succeds, it returns the last chunk in that contiguous
-//! sequence, so that the sequence is known by [start, {retval}]
-//! If it fails, it does do either because it's at the end of the
-//! free list or hits a non-contiguous chunk. In either case,
-//! it will return 0, and set start to the last considered
-//! chunk. You are at the end of the free list if
-//! nextof(start) == 0. Otherwise, start points to the last
-//! chunk in the contiguous sequence, and nextof(start) points
-//! to the first chunk in the next contiguous sequence (assuming
-//! an ordered free list).
-template <typename SizeType>
-void * simple_segregated_storage<SizeType>::try_malloc_n(
- void * & start, size_type n, const size_type partition_size)
-{
- void * iter = nextof(start);
- while (--n != 0)
- {
- void * next = nextof(iter);
- if (next != static_cast<char *>(iter) + partition_size)
- {
- // next == 0 (end-of-list) or non-contiguous chunk found
- start = iter;
- return 0;
- }
- iter = next;
- }
- return iter;
-}
-
-//! Attempts to find a contiguous sequence of n partition_sz-sized chunks. If found, removes them
-//! all from the free list and returns a pointer to the first. If not found, returns 0. It is strongly
-//! recommended (but not required) that the free list be ordered, as this algorithm will fail to find
-//! a contiguous sequence unless it is contiguous in the free list as well. Order-preserving.
-//! O(N) with respect to the size of the free list.
-template <typename SizeType>
-void * simple_segregated_storage<SizeType>::malloc_n(const size_type n,
- const size_type partition_size)
-{
- BOOST_POOL_VALIDATE_INTERNALS
- if(n == 0)
- return 0;
- void * start = &first;
- void * iter;
- do
- {
- if (nextof(start) == 0)
- return 0;
- iter = try_malloc_n(start, n, partition_size);
- } while (iter == 0);
- void * const ret = nextof(start);
- nextof(start) = nextof(iter);
- BOOST_POOL_VALIDATE_INTERNALS
- return ret;
-}
-
-} // namespace boost
-
-#ifdef BOOST_MSVC
-#pragma warning(pop)
-#endif
-
-#endif
diff --git a/contrib/restricted/boost/boost/pool/singleton_pool.hpp b/contrib/restricted/boost/boost/pool/singleton_pool.hpp
deleted file mode 100644
index b79353be91e..00000000000
--- a/contrib/restricted/boost/boost/pool/singleton_pool.hpp
+++ /dev/null
@@ -1,251 +0,0 @@
-// Copyright (C) 2000, 2001 Stephen Cleary
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org for updates, documentation, and revision history.
-
-#ifndef BOOST_SINGLETON_POOL_HPP
-#define BOOST_SINGLETON_POOL_HPP
-
-/*!
- \file
- \brief The <tt>singleton_pool</tt> class allows other pool interfaces
- for types of the same size to share the same underlying pool.
-
- \details Header singleton_pool.hpp provides a template class <tt>singleton_pool</tt>,
- which provides access to a pool as a singleton object.
-
-*/
-
-#include <boost/pool/poolfwd.hpp>
-
-// boost::pool
-#include <boost/pool/pool.hpp>
-// boost::details::pool::guard
-#include <boost/pool/detail/guard.hpp>
-
-#include <boost/type_traits/aligned_storage.hpp>
-
-namespace boost {
-
- /*!
- The singleton_pool class allows other pool interfaces
- for types of the same size to share the same pool. Template
- parameters are as follows:
-
- <b>Tag</b> User-specified type to uniquely identify this pool: allows different unbounded sets of singleton pools to exist.
-
- <b>RequestedSize</b> The size of each chunk returned by member function <tt>malloc()</tt>.
-
- <B>UserAllocator</b> User allocator, default = default_user_allocator_new_delete.
-
- <b>Mutex</B> This class is the type of mutex to use to protect simultaneous access to the underlying Pool.
- Can be any Boost.Thread Mutex type or <tt>boost::details::pool::null_mutex</tt>.
- It is exposed so that users may declare some singleton pools normally (i.e., with synchronization), but
- some singleton pools without synchronization (by specifying <tt>boost::details::pool::null_mutex</tt>) for efficiency reasons.
- The member typedef <tt>mutex</tt> exposes the value of this template parameter. The default for this
- parameter is boost::details::pool::default_mutex which is a synonym for either <tt>boost::details::pool::null_mutex</tt>
- (when threading support is turned off in the compiler (so BOOST_HAS_THREADS is not set), or threading support
- has ben explicitly disabled with BOOST_DISABLE_THREADS (Boost-wide disabling of threads) or BOOST_POOL_NO_MT (this library only))
- or for <tt>boost::mutex</tt> (when threading support is enabled in the compiler).
-
- <B>NextSize</b> The value of this parameter is passed to the underlying Pool when it is created and
- specifies the number of chunks to allocate in the first allocation request (defaults to 32).
- The member typedef <tt>static const value next_size</tt> exposes the value of this template parameter.
-
- <b>MaxSize</B>The value of this parameter is passed to the underlying Pool when it is created and
- specifies the maximum number of chunks to allocate in any single allocation request (defaults to 0).
-
- <b>Notes:</b>
-
- The underlying pool <i>p</i> referenced by the static functions
- in singleton_pool is actually declared in a way that is:
-
- 1 Thread-safe if there is only one thread running before main() begins and after main() ends
- -- all of the static functions of singleton_pool synchronize their access to p.
-
- 2 Guaranteed to be constructed before it is used --
- thus, the simple static object in the synopsis above would actually be an incorrect implementation.
- The actual implementation to guarantee this is considerably more complicated.
-
- 3 Note too that a different underlying pool p exists
- for each different set of template parameters,
- including implementation-specific ones.
-
- 4 The underlying pool is constructed "as if" by:
-
- pool<UserAllocator> p(RequestedSize, NextSize, MaxSize);
-
- \attention
- The underlying pool constructed by the singleton
- <b>is never freed</b>. This means that memory allocated
- by a singleton_pool can be still used after main() has
- completed, but may mean that some memory checking programs
- will complain about leaks from singleton_pool.
-
- */
-
- template <typename Tag,
- unsigned RequestedSize,
- typename UserAllocator,
- typename Mutex,
- unsigned NextSize,
- unsigned MaxSize >
-class singleton_pool
-{
- public:
- typedef Tag tag; /*!< The Tag template parameter uniquely
- identifies this pool and allows
- different unbounded sets of singleton pools to exist.
- For example, the pool allocators use two tag classes to ensure that the
- two different allocator types never share the same underlying singleton pool.
- Tag is never actually used by singleton_pool.
- */
- typedef Mutex mutex; //!< The type of mutex used to synchonise access to this pool (default <tt>details::pool::default_mutex</tt>).
- typedef UserAllocator user_allocator; //!< The user-allocator used by this pool, default = <tt>default_user_allocator_new_delete</tt>.
- typedef typename pool<UserAllocator>::size_type size_type; //!< size_type of user allocator.
- typedef typename pool<UserAllocator>::difference_type difference_type; //!< difference_type of user allocator.
-
- BOOST_STATIC_CONSTANT(unsigned, requested_size = RequestedSize); //!< The size of each chunk allocated by this pool.
- BOOST_STATIC_CONSTANT(unsigned, next_size = NextSize); //!< The number of chunks to allocate on the first allocation.
-
-private:
- singleton_pool();
-
-#ifndef BOOST_DOXYGEN
- struct pool_type: public Mutex, public pool<UserAllocator>
- {
- pool_type() : pool<UserAllocator>(RequestedSize, NextSize, MaxSize) {}
- }; // struct pool_type: Mutex
-
-#else
- //
- // This is invoked when we build with Doxygen only:
- //
-public:
- static pool<UserAllocator> p; //!< For exposition only!
-#endif
-
-
- public:
- static void * malloc BOOST_PREVENT_MACRO_SUBSTITUTION()
- { //! Equivalent to SingletonPool::p.malloc(); synchronized.
- pool_type & p = get_pool();
- details::pool::guard<Mutex> g(p);
- return (p.malloc)();
- }
- static void * ordered_malloc()
- { //! Equivalent to SingletonPool::p.ordered_malloc(); synchronized.
- pool_type & p = get_pool();
- details::pool::guard<Mutex> g(p);
- return p.ordered_malloc();
- }
- static void * ordered_malloc(const size_type n)
- { //! Equivalent to SingletonPool::p.ordered_malloc(n); synchronized.
- pool_type & p = get_pool();
- details::pool::guard<Mutex> g(p);
- return p.ordered_malloc(n);
- }
- static bool is_from(void * const ptr)
- { //! Equivalent to SingletonPool::p.is_from(chunk); synchronized.
- //! \returns true if chunk is from SingletonPool::is_from(chunk)
- pool_type & p = get_pool();
- details::pool::guard<Mutex> g(p);
- return p.is_from(ptr);
- }
- static void free BOOST_PREVENT_MACRO_SUBSTITUTION(void * const ptr)
- { //! Equivalent to SingletonPool::p.free(chunk); synchronized.
- pool_type & p = get_pool();
- details::pool::guard<Mutex> g(p);
- (p.free)(ptr);
- }
- static void ordered_free(void * const ptr)
- { //! Equivalent to SingletonPool::p.ordered_free(chunk); synchronized.
- pool_type & p = get_pool();
- details::pool::guard<Mutex> g(p);
- p.ordered_free(ptr);
- }
- static void free BOOST_PREVENT_MACRO_SUBSTITUTION(void * const ptr, const size_type n)
- { //! Equivalent to SingletonPool::p.free(chunk, n); synchronized.
- pool_type & p = get_pool();
- details::pool::guard<Mutex> g(p);
- (p.free)(ptr, n);
- }
- static void ordered_free(void * const ptr, const size_type n)
- { //! Equivalent to SingletonPool::p.ordered_free(chunk, n); synchronized.
- pool_type & p = get_pool();
- details::pool::guard<Mutex> g(p);
- p.ordered_free(ptr, n);
- }
- static bool release_memory()
- { //! Equivalent to SingletonPool::p.release_memory(); synchronized.
- pool_type & p = get_pool();
- details::pool::guard<Mutex> g(p);
- return p.release_memory();
- }
- static bool purge_memory()
- { //! Equivalent to SingletonPool::p.purge_memory(); synchronized.
- pool_type & p = get_pool();
- details::pool::guard<Mutex> g(p);
- return p.purge_memory();
- }
-
-private:
- typedef boost::aligned_storage<sizeof(pool_type), boost::alignment_of<pool_type>::value> storage_type;
- static storage_type storage;
-
- static pool_type& get_pool()
- {
- static bool f = false;
- if(!f)
- {
- // This code *must* be called before main() starts,
- // and when only one thread is executing.
- f = true;
- new (&storage) pool_type;
- }
-
- // The following line does nothing else than force the instantiation
- // of singleton<T>::create_object, whose constructor is
- // called before main() begins.
- create_object.do_nothing();
-
- return *static_cast<pool_type*>(static_cast<void*>(&storage));
- }
-
- struct object_creator
- {
- object_creator()
- { // This constructor does nothing more than ensure that instance()
- // is called before main() begins, thus creating the static
- // T object before multithreading race issues can come up.
- singleton_pool<Tag, RequestedSize, UserAllocator, Mutex, NextSize, MaxSize>::get_pool();
- }
- inline void do_nothing() const
- {
- }
- };
- static object_creator create_object;
-}; // struct singleton_pool
-
-template <typename Tag,
- unsigned RequestedSize,
- typename UserAllocator,
- typename Mutex,
- unsigned NextSize,
- unsigned MaxSize >
-typename singleton_pool<Tag, RequestedSize, UserAllocator, Mutex, NextSize, MaxSize>::storage_type singleton_pool<Tag, RequestedSize, UserAllocator, Mutex, NextSize, MaxSize>::storage;
-
-template <typename Tag,
- unsigned RequestedSize,
- typename UserAllocator,
- typename Mutex,
- unsigned NextSize,
- unsigned MaxSize >
-typename singleton_pool<Tag, RequestedSize, UserAllocator, Mutex, NextSize, MaxSize>::object_creator singleton_pool<Tag, RequestedSize, UserAllocator, Mutex, NextSize, MaxSize>::create_object;
-
-} // namespace boost
-
-#endif
diff --git a/contrib/restricted/boost/pool/CMakeLists.txt b/contrib/restricted/boost/pool/CMakeLists.txt
new file mode 100644
index 00000000000..5dafbc11407
--- /dev/null
+++ b/contrib/restricted/boost/pool/CMakeLists.txt
@@ -0,0 +1,22 @@
+
+# This file was gererated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(restricted-boost-pool INTERFACE)
+target_include_directories(restricted-boost-pool INTERFACE
+ ${CMAKE_SOURCE_DIR}/contrib/restricted/boost/pool/include
+)
+target_link_libraries(restricted-boost-pool INTERFACE
+ contrib-libs-cxxsupp
+ yutil
+ restricted-boost-assert
+ restricted-boost-config
+ restricted-boost-integer
+ restricted-boost-throw_exception
+ restricted-boost-type_traits
+)