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@101
|
16 #ifndef BOOST_CONFIG_HPP
|
Chris@101
|
17 # include <boost/config.hpp>
|
Chris@101
|
18 #endif
|
Chris@101
|
19 #
|
Chris@101
|
20 #if defined(BOOST_HAS_PRAGMA_ONCE)
|
Chris@16
|
21 # pragma once
|
Chris@16
|
22 #endif
|
Chris@16
|
23
|
Chris@16
|
24 #include <boost/interprocess/detail/config_begin.hpp>
|
Chris@16
|
25 #include <boost/interprocess/interprocess_fwd.hpp>
|
Chris@16
|
26 #include <boost/interprocess/detail/utilities.hpp>
|
Chris@16
|
27 #include <boost/intrusive/pointer_traits.hpp>
|
Chris@16
|
28
|
Chris@16
|
29 //!\file
|
Chris@16
|
30 //!Describes the functor to delete objects from the segment.
|
Chris@16
|
31
|
Chris@16
|
32 namespace boost {
|
Chris@16
|
33 namespace interprocess {
|
Chris@16
|
34
|
Chris@16
|
35 //!A deleter that uses the segment manager's destroy_ptr
|
Chris@16
|
36 //!function to destroy the passed pointer resource.
|
Chris@16
|
37 //!
|
Chris@16
|
38 //!This deleter is used
|
Chris@16
|
39 template<class T, class SegmentManager>
|
Chris@16
|
40 class deleter
|
Chris@16
|
41 {
|
Chris@16
|
42 public:
|
Chris@16
|
43 typedef typename boost::intrusive::
|
Chris@16
|
44 pointer_traits<typename SegmentManager::void_pointer>::template
|
Chris@16
|
45 rebind_pointer<T>::type pointer;
|
Chris@16
|
46
|
Chris@16
|
47 private:
|
Chris@16
|
48 typedef typename boost::intrusive::
|
Chris@16
|
49 pointer_traits<pointer>::template
|
Chris@16
|
50 rebind_pointer<SegmentManager>::type segment_manager_pointer;
|
Chris@16
|
51
|
Chris@16
|
52 segment_manager_pointer mp_mngr;
|
Chris@16
|
53
|
Chris@16
|
54 public:
|
Chris@16
|
55 deleter(segment_manager_pointer pmngr)
|
Chris@16
|
56 : mp_mngr(pmngr)
|
Chris@16
|
57 {}
|
Chris@16
|
58
|
Chris@16
|
59 void operator()(const pointer &p)
|
Chris@16
|
60 { mp_mngr->destroy_ptr(ipcdetail::to_raw_pointer(p)); }
|
Chris@16
|
61 };
|
Chris@16
|
62
|
Chris@16
|
63 } //namespace interprocess {
|
Chris@16
|
64 } //namespace boost {
|
Chris@16
|
65
|
Chris@16
|
66 #include <boost/interprocess/detail/config_end.hpp>
|
Chris@16
|
67
|
Chris@16
|
68 #endif //#ifndef BOOST_INTERPROCESS_DELETER_HPP
|