Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / thread / detail / memory.hpp
1 //////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2011-2013 Vicente J. Botet Escriba
4 //
5 //  Distributed under the Boost Software License, Version 1.0. (See accompanying
6 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 //
8 // See http://www.boost.org/libs/thread for documentation.
9 //
10 //////////////////////////////////////////////////////////////////////////////
11
12 #ifndef BOOST_THREAD_DETAIL_MEMORY_HPP
13 #define BOOST_THREAD_DETAIL_MEMORY_HPP
14
15 #include <boost/config.hpp>
16
17 #include <boost/thread/csbl/memory/pointer_traits.hpp>
18 #include <boost/thread/csbl/memory/allocator_arg.hpp>
19 #include <boost/thread/csbl/memory/allocator_traits.hpp>
20 #include <boost/thread/csbl/memory/scoped_allocator.hpp>
21
22 namespace boost
23 {
24   namespace thread_detail
25   {
26     template <class _Alloc>
27     class allocator_destructor
28     {
29       typedef csbl::allocator_traits<_Alloc> alloc_traits;
30     public:
31       typedef typename alloc_traits::pointer pointer;
32       typedef typename alloc_traits::size_type size_type;
33     private:
34       _Alloc alloc_;
35       size_type s_;
36     public:
37       allocator_destructor(_Alloc& a, size_type s)BOOST_NOEXCEPT
38       : alloc_(a), s_(s)
39       {}
40       void operator()(pointer p)BOOST_NOEXCEPT
41       {
42         alloc_traits::destroy(alloc_, p);
43         alloc_traits::deallocate(alloc_, p, s_);
44       }
45     };
46   } //namespace thread_detail
47 }
48 #endif //  BOOST_THREAD_DETAIL_MEMORY_HPP