deleter.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #ifndef BOOST_INTERPROCESS_DELETER_HPP
  13. #define BOOST_INTERPROCESS_DELETER_HPP
  14. #if (defined _MSC_VER) && (_MSC_VER >= 1200)
  15. # pragma once
  16. #endif
  17. #include <boost/interprocess/detail/config_begin.hpp>
  18. #include <boost/interprocess/interprocess_fwd.hpp>
  19. #include <boost/interprocess/detail/utilities.hpp>
  20. #include <boost/intrusive/pointer_traits.hpp>
  21. //!\file
  22. //!Describes the functor to delete objects from the segment.
  23. namespace boost {
  24. namespace interprocess {
  25. //!A deleter that uses the segment manager's destroy_ptr
  26. //!function to destroy the passed pointer resource.
  27. //!
  28. //!This deleter is used
  29. template<class T, class SegmentManager>
  30. class deleter
  31. {
  32. public:
  33. typedef typename boost::intrusive::
  34. pointer_traits<typename SegmentManager::void_pointer>::template
  35. rebind_pointer<T>::type pointer;
  36. private:
  37. typedef typename boost::intrusive::
  38. pointer_traits<pointer>::template
  39. rebind_pointer<SegmentManager>::type segment_manager_pointer;
  40. segment_manager_pointer mp_mngr;
  41. public:
  42. deleter(segment_manager_pointer pmngr)
  43. : mp_mngr(pmngr)
  44. {}
  45. void operator()(const pointer &p)
  46. { mp_mngr->destroy_ptr(ipcdetail::to_raw_pointer(p)); }
  47. };
  48. } //namespace interprocess {
  49. } //namespace boost {
  50. #include <boost/interprocess/detail/config_end.hpp>
  51. #endif //#ifndef BOOST_INTERPROCESS_DELETER_HPP