Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:34

0001 //////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
0004 // Software License, Version 1.0. (See accompanying file
0005 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // See http://www.boost.org/libs/interprocess for documentation.
0008 //
0009 //////////////////////////////////////////////////////////////////////////////
0010 
0011 #ifndef BOOST_INTERPROCESS_MANAGED_EXTERNAL_BUFFER_HPP
0012 #define BOOST_INTERPROCESS_MANAGED_EXTERNAL_BUFFER_HPP
0013 
0014 #ifndef BOOST_CONFIG_HPP
0015 #  include <boost/config.hpp>
0016 #endif
0017 #
0018 #if defined(BOOST_HAS_PRAGMA_ONCE)
0019 #  pragma once
0020 #endif
0021 
0022 #include <boost/interprocess/detail/config_begin.hpp>
0023 #include <boost/interprocess/detail/workaround.hpp>
0024 #include <boost/interprocess/creation_tags.hpp>
0025 #include <boost/interprocess/detail/managed_memory_impl.hpp>
0026 #include <boost/move/utility_core.hpp>
0027 #include <boost/assert.hpp>
0028 //These includes needed to fulfill default template parameters of
0029 //predeclarations in interprocess_fwd.hpp
0030 #include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
0031 #include <boost/interprocess/sync/mutex_family.hpp>
0032 #include <boost/interprocess/indexes/iset_index.hpp>
0033 
0034 //!\file
0035 //!Describes a named user memory allocation user class.
0036 
0037 namespace boost {
0038 namespace interprocess {
0039 
0040 //!A basic user memory named object creation class. Inherits all
0041 //!basic functionality from
0042 //!basic_managed_memory_impl<CharType, AllocationAlgorithm, IndexType>*/
0043 template
0044       <
0045          class CharType,
0046          class AllocationAlgorithm,
0047          template<class IndexConfig> class IndexType
0048       >
0049 class basic_managed_external_buffer
0050    : public ipcdetail::basic_managed_memory_impl <CharType, AllocationAlgorithm, IndexType>
0051 {
0052    #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0053    typedef ipcdetail::basic_managed_memory_impl
0054       <CharType, AllocationAlgorithm, IndexType>    base_t;
0055    BOOST_MOVABLE_BUT_NOT_COPYABLE(basic_managed_external_buffer)
0056    #endif   //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0057 
0058    public:
0059    typedef typename base_t::size_type              size_type;
0060 
0061    //!Default constructor. Does nothing.
0062    //!Useful in combination with move semantics
0063    basic_managed_external_buffer() BOOST_NOEXCEPT
0064    {}
0065 
0066    //!Creates and places the segment manager. This can throw
0067    //!The external memory supplied by the user shall be aligned to the maximum value between 
0068    //!`alignof(std::max_align_t)` and the strictest alignment of any over-aligned type to be built
0069    //!inside that memory.
0070    basic_managed_external_buffer
0071       (create_only_t, void *addr, size_type size)
0072    {
0073       //Check if alignment is correct
0074       BOOST_ASSERT((0 == (((std::size_t)addr) & (AllocationAlgorithm::Alignment - size_type(1u)))));
0075       if(!base_t::create_impl(addr, size)){
0076          throw interprocess_exception("Could not initialize buffer in basic_managed_external_buffer constructor");
0077       }
0078    }
0079 
0080    //!Creates and places the segment manager. This can throw
0081    //!The external memory supplied by the user shall be aligned to the maximum value between 
0082    //!`alignof(std::max_align_t)` and the strictest alignment of any over-aligned type to be built
0083    //!inside that memory.
0084    basic_managed_external_buffer
0085       (open_only_t, void *addr, size_type size)
0086    {
0087       //Check if alignment is correct
0088       BOOST_ASSERT((0 == (((std::size_t)addr) & (AllocationAlgorithm::Alignment - size_type(1u)))));
0089       if(!base_t::open_impl(addr, size)){
0090          throw interprocess_exception("Could not initialize buffer in basic_managed_external_buffer constructor");
0091       }
0092    }
0093 
0094    //!Moves the ownership of "moved"'s managed memory to *this. Does not throw
0095    basic_managed_external_buffer(BOOST_RV_REF(basic_managed_external_buffer) moved) BOOST_NOEXCEPT
0096    {
0097       this->swap(moved);
0098    }
0099 
0100    //!Moves the ownership of "moved"'s managed memory to *this. Does not throw
0101    basic_managed_external_buffer &operator=(BOOST_RV_REF(basic_managed_external_buffer) moved) BOOST_NOEXCEPT
0102    {
0103       basic_managed_external_buffer tmp(boost::move(moved));
0104       this->swap(tmp);
0105       return *this;
0106    }
0107 
0108    void grow(size_type extra_bytes)
0109    {  base_t::grow(extra_bytes);   }
0110 
0111    //!Swaps the ownership of the managed heap memories managed by *this and other.
0112    //!Never throws.
0113    void swap(basic_managed_external_buffer &other) BOOST_NOEXCEPT
0114    {  base_t::swap(other); }
0115 };
0116 
0117 #ifdef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0118 
0119 //!Typedef for a default basic_managed_external_buffer
0120 //!of narrow characters
0121 typedef basic_managed_external_buffer
0122    <char
0123    ,rbtree_best_fit<null_mutex_family>
0124    ,iset_index>
0125 managed_external_buffer;
0126 
0127 //!Typedef for a default basic_managed_external_buffer
0128 //!of wide characters
0129 typedef basic_managed_external_buffer
0130    <wchar_t
0131    ,rbtree_best_fit<null_mutex_family>
0132    ,iset_index>
0133 wmanaged_external_buffer;
0134 
0135 #endif   //#ifdef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0136 
0137 }  //namespace interprocess {
0138 }  //namespace boost {
0139 
0140 #include <boost/interprocess/detail/config_end.hpp>
0141 
0142 #endif   //BOOST_INTERPROCESS_MANAGED_EXTERNAL_BUFFER_HPP
0143