1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2005-2008. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/interprocess for documentation.
9 //////////////////////////////////////////////////////////////////////////////
11 #ifndef BOOST_INTERPROCESS_MANAGED_EXTERNAL_BUFFER_HPP
12 #define BOOST_INTERPROCESS_MANAGED_EXTERNAL_BUFFER_HPP
14 #if (defined _MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/interprocess/detail/config_begin.hpp>
19 #include <boost/interprocess/detail/workaround.hpp>
20 #include <boost/interprocess/creation_tags.hpp>
21 #include <boost/interprocess/detail/managed_memory_impl.hpp>
22 #include <boost/interprocess/detail/move.hpp>
26 //!Describes a named user memory allocation user class.
29 namespace interprocess
{
31 //!A basic user memory named object creation class. Inherits all
32 //!basic functionality from
33 //!basic_managed_memory_impl<CharType, AllocationAlgorithm, IndexType>*/
37 class AllocationAlgorithm
,
38 template<class IndexConfig
> class IndexType
40 class basic_managed_external_buffer
41 : public detail::basic_managed_memory_impl
<CharType
, AllocationAlgorithm
, IndexType
>
44 typedef detail::basic_managed_memory_impl
45 <CharType
, AllocationAlgorithm
, IndexType
> base_t
;
46 basic_managed_external_buffer(basic_managed_external_buffer
&);
47 basic_managed_external_buffer
& operator=(basic_managed_external_buffer
&);
51 BOOST_INTERPROCESS_ENABLE_MOVE_EMULATION(basic_managed_external_buffer
)
53 //!Default constructor. Does nothing.
54 //!Useful in combination with move semantics
55 basic_managed_external_buffer()
58 //!Creates and places the segment manager. This can throw
59 basic_managed_external_buffer
60 (create_only_t
, void *addr
, std::size_t size
)
62 //Check if alignment is correct
63 assert((0 == (((std::size_t)addr
) & (AllocationAlgorithm::Alignment
- std::size_t(1u)))));
64 if(!base_t::create_impl(addr
, size
)){
65 throw interprocess_exception();
69 //!Creates and places the segment manager. This can throw
70 basic_managed_external_buffer
71 (open_only_t
, void *addr
, std::size_t size
)
73 //Check if alignment is correct
74 assert((0 == (((std::size_t)addr
) & (AllocationAlgorithm::Alignment
- std::size_t(1u)))));
75 if(!base_t::open_impl(addr
, size
)){
76 throw interprocess_exception();
80 //!Moves the ownership of "moved"'s managed memory to *this. Does not throw
81 basic_managed_external_buffer(BOOST_INTERPROCESS_RV_REF(basic_managed_external_buffer
) moved
)
86 //!Moves the ownership of "moved"'s managed memory to *this. Does not throw
87 basic_managed_external_buffer
&operator=(BOOST_INTERPROCESS_RV_REF(basic_managed_external_buffer
) moved
)
89 basic_managed_external_buffer
tmp(boost::interprocess::move(moved
));
94 void grow(std::size_t extra_bytes
)
95 { base_t::grow(extra_bytes
); }
97 //!Swaps the ownership of the managed heap memories managed by *this and other.
99 void swap(basic_managed_external_buffer
&other
)
100 { base_t::swap(other
); }
103 } //namespace interprocess {
104 } //namespace boost {
106 #include <boost/interprocess/detail/config_end.hpp>
108 #endif //BOOST_INTERPROCESS_MANAGED_EXTERNAL_BUFFER_HPP