]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/container/src/synchronized_pool_resource.cpp
1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2015-2015. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/container for documentation.
9 //////////////////////////////////////////////////////////////////////////////
11 #define BOOST_CONTAINER_SOURCE
12 #include <boost/container/detail/config_begin.hpp>
13 #include <boost/container/detail/workaround.hpp>
14 #include <boost/container/detail/thread_mutex.hpp>
16 #include <boost/container/pmr/synchronized_pool_resource.hpp>
21 using namespace boost::container::dtl
;
23 class thread_mutex_lock
28 explicit thread_mutex_lock(thread_mutex
&m
)
46 synchronized_pool_resource::synchronized_pool_resource(const pool_options
& opts
, memory_resource
* upstream
) BOOST_NOEXCEPT
47 : m_mut(), m_pool_resource(opts
, upstream
)
50 synchronized_pool_resource::synchronized_pool_resource() BOOST_NOEXCEPT
51 : m_mut(), m_pool_resource()
54 synchronized_pool_resource::synchronized_pool_resource(memory_resource
* upstream
) BOOST_NOEXCEPT
55 : m_mut(), m_pool_resource(upstream
)
58 synchronized_pool_resource::synchronized_pool_resource(const pool_options
& opts
) BOOST_NOEXCEPT
59 : m_mut(), m_pool_resource(opts
)
62 synchronized_pool_resource::~synchronized_pool_resource() //virtual
65 void synchronized_pool_resource::release()
67 thread_mutex_lock
lck(m_mut
); (void)lck
;
68 m_pool_resource
.release();
71 memory_resource
* synchronized_pool_resource::upstream_resource() const
72 { return m_pool_resource
.upstream_resource(); }
74 pool_options
synchronized_pool_resource::options() const
75 { return m_pool_resource
.options(); }
77 void* synchronized_pool_resource::do_allocate(std::size_t bytes
, std::size_t alignment
) //virtual
79 thread_mutex_lock
lck(m_mut
); (void)lck
;
80 return m_pool_resource
.do_allocate(bytes
, alignment
);
83 void synchronized_pool_resource::do_deallocate(void* p
, std::size_t bytes
, std::size_t alignment
) //virtual
85 thread_mutex_lock
lck(m_mut
); (void)lck
;
86 return m_pool_resource
.do_deallocate(p
, bytes
, alignment
);
89 bool synchronized_pool_resource::do_is_equal(const memory_resource
& other
) const BOOST_NOEXCEPT
//virtual
90 { return this == &other
; }
92 std::size_t synchronized_pool_resource::pool_count() const
93 { return m_pool_resource
.pool_count(); }
95 std::size_t synchronized_pool_resource::pool_index(std::size_t bytes
) const
96 { return m_pool_resource
.pool_index(bytes
); }
98 std::size_t synchronized_pool_resource::pool_next_blocks_per_chunk(std::size_t pool_idx
) const
99 { return m_pool_resource
.pool_next_blocks_per_chunk(pool_idx
); }
101 std::size_t synchronized_pool_resource::pool_block(std::size_t pool_idx
) const
102 { return m_pool_resource
.pool_block(pool_idx
); }
104 std::size_t synchronized_pool_resource::pool_cached_blocks(std::size_t pool_idx
) const
105 { return m_pool_resource
.pool_cached_blocks(pool_idx
); }
108 } //namespace container {
109 } //namespace boost {
111 #include <boost/container/detail/config_end.hpp>