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