Chris@16
|
1 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 //
|
Chris@16
|
3 // (C) Copyright Ion Gaztanaga 2007-2012.
|
Chris@16
|
4 //
|
Chris@16
|
5 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
6 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
7 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8 //
|
Chris@16
|
9 // See http://www.boost.org/libs/interprocess for documentation.
|
Chris@16
|
10 //
|
Chris@16
|
11 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
12
|
Chris@16
|
13 #ifndef BOOST_INTERPROCESS_DELETER_HPP
|
Chris@16
|
14 #define BOOST_INTERPROCESS_DELETER_HPP
|
Chris@16
|
15
|
Chris@16
|
16 #if (defined _MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
17 # pragma once
|
Chris@16
|
18 #endif
|
Chris@16
|
19
|
Chris@16
|
20 #include <boost/interprocess/detail/config_begin.hpp>
|
Chris@16
|
21 #include <boost/interprocess/interprocess_fwd.hpp>
|
Chris@16
|
22 #include <boost/interprocess/detail/utilities.hpp>
|
Chris@16
|
23 #include <boost/intrusive/pointer_traits.hpp>
|
Chris@16
|
24
|
Chris@16
|
25 //!\file
|
Chris@16
|
26 //!Describes the functor to delete objects from the segment.
|
Chris@16
|
27
|
Chris@16
|
28 namespace boost {
|
Chris@16
|
29 namespace interprocess {
|
Chris@16
|
30
|
Chris@16
|
31 //!A deleter that uses the segment manager's destroy_ptr
|
Chris@16
|
32 //!function to destroy the passed pointer resource.
|
Chris@16
|
33 //!
|
Chris@16
|
34 //!This deleter is used
|
Chris@16
|
35 template<class T, class SegmentManager>
|
Chris@16
|
36 class deleter
|
Chris@16
|
37 {
|
Chris@16
|
38 public:
|
Chris@16
|
39 typedef typename boost::intrusive::
|
Chris@16
|
40 pointer_traits<typename SegmentManager::void_pointer>::template
|
Chris@16
|
41 rebind_pointer<T>::type pointer;
|
Chris@16
|
42
|
Chris@16
|
43 private:
|
Chris@16
|
44 typedef typename boost::intrusive::
|
Chris@16
|
45 pointer_traits<pointer>::template
|
Chris@16
|
46 rebind_pointer<SegmentManager>::type segment_manager_pointer;
|
Chris@16
|
47
|
Chris@16
|
48 segment_manager_pointer mp_mngr;
|
Chris@16
|
49
|
Chris@16
|
50 public:
|
Chris@16
|
51 deleter(segment_manager_pointer pmngr)
|
Chris@16
|
52 : mp_mngr(pmngr)
|
Chris@16
|
53 {}
|
Chris@16
|
54
|
Chris@16
|
55 void operator()(const pointer &p)
|
Chris@16
|
56 { mp_mngr->destroy_ptr(ipcdetail::to_raw_pointer(p)); }
|
Chris@16
|
57 };
|
Chris@16
|
58
|
Chris@16
|
59 } //namespace interprocess {
|
Chris@16
|
60 } //namespace boost {
|
Chris@16
|
61
|
Chris@16
|
62 #include <boost/interprocess/detail/config_end.hpp>
|
Chris@16
|
63
|
Chris@16
|
64 #endif //#ifndef BOOST_INTERPROCESS_DELETER_HPP
|