Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-08 08:23:10

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