Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/interprocess/file_mapping.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
comparison
equal
deleted
inserted
replaced
100:793467b5e61c | 101:c530137014c0 |
---|---|
9 ////////////////////////////////////////////////////////////////////////////// | 9 ////////////////////////////////////////////////////////////////////////////// |
10 | 10 |
11 #ifndef BOOST_INTERPROCESS_FILE_MAPPING_HPP | 11 #ifndef BOOST_INTERPROCESS_FILE_MAPPING_HPP |
12 #define BOOST_INTERPROCESS_FILE_MAPPING_HPP | 12 #define BOOST_INTERPROCESS_FILE_MAPPING_HPP |
13 | 13 |
14 #ifndef BOOST_CONFIG_HPP | |
15 # include <boost/config.hpp> | |
16 #endif | |
17 # | |
18 #if defined(BOOST_HAS_PRAGMA_ONCE) | |
19 # pragma once | |
20 #endif | |
21 | |
14 #include <boost/interprocess/detail/config_begin.hpp> | 22 #include <boost/interprocess/detail/config_begin.hpp> |
15 #include <boost/interprocess/detail/workaround.hpp> | 23 #include <boost/interprocess/detail/workaround.hpp> |
24 | |
25 #if !defined(BOOST_INTERPROCESS_MAPPED_FILES) | |
26 #error "Boost.Interprocess: This platform does not support memory mapped files!" | |
27 #endif | |
16 | 28 |
17 #include <boost/interprocess/interprocess_fwd.hpp> | 29 #include <boost/interprocess/interprocess_fwd.hpp> |
18 #include <boost/interprocess/exceptions.hpp> | 30 #include <boost/interprocess/exceptions.hpp> |
19 #include <boost/interprocess/detail/utilities.hpp> | 31 #include <boost/interprocess/detail/utilities.hpp> |
20 #include <boost/interprocess/creation_tags.hpp> | 32 #include <boost/interprocess/creation_tags.hpp> |
21 #include <boost/interprocess/detail/os_file_functions.hpp> | 33 #include <boost/interprocess/detail/os_file_functions.hpp> |
22 #include <boost/move/move.hpp> | 34 #include <boost/interprocess/detail/simple_swap.hpp> |
35 #include <boost/move/utility_core.hpp> | |
23 #include <string> //std::string | 36 #include <string> //std::string |
24 | 37 |
25 //!\file | 38 //!\file |
26 //!Describes file_mapping and mapped region classes | 39 //!Describes file_mapping and mapped region classes |
27 | 40 |
30 | 43 |
31 //!A class that wraps a file-mapping that can be used to | 44 //!A class that wraps a file-mapping that can be used to |
32 //!create mapped regions from the mapped files | 45 //!create mapped regions from the mapped files |
33 class file_mapping | 46 class file_mapping |
34 { | 47 { |
35 /// @cond | 48 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) |
36 BOOST_MOVABLE_BUT_NOT_COPYABLE(file_mapping) | 49 BOOST_MOVABLE_BUT_NOT_COPYABLE(file_mapping) |
37 /// @endcond | 50 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED |
38 | 51 |
39 public: | 52 public: |
40 //!Constructs an empty file mapping. | 53 //!Constructs an empty file mapping. |
41 //!Does not throw | 54 //!Does not throw |
42 file_mapping(); | 55 file_mapping(); |
89 //!Returns true on success. | 102 //!Returns true on success. |
90 //!The function might fail in some operating systems if the file is | 103 //!The function might fail in some operating systems if the file is |
91 //!being used other processes and no deletion permission was shared. | 104 //!being used other processes and no deletion permission was shared. |
92 static bool remove(const char *filename); | 105 static bool remove(const char *filename); |
93 | 106 |
94 /// @cond | 107 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) |
95 private: | 108 private: |
96 //!Closes a previously opened file mapping. Never throws. | 109 //!Closes a previously opened file mapping. Never throws. |
97 void priv_close(); | 110 void priv_close(); |
98 file_handle_t m_handle; | 111 file_handle_t m_handle; |
99 mode_t m_mode; | 112 mode_t m_mode; |
100 std::string m_filename; | 113 std::string m_filename; |
101 /// @endcond | 114 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED |
102 }; | 115 }; |
103 | 116 |
104 inline file_mapping::file_mapping() | 117 inline file_mapping::file_mapping() |
105 : m_handle(file_handle_t(ipcdetail::invalid_file())) | 118 : m_handle(file_handle_t(ipcdetail::invalid_file())) |
106 , m_mode(read_only) | 119 , m_mode(read_only) |
112 inline const char *file_mapping::get_name() const | 125 inline const char *file_mapping::get_name() const |
113 { return m_filename.c_str(); } | 126 { return m_filename.c_str(); } |
114 | 127 |
115 inline void file_mapping::swap(file_mapping &other) | 128 inline void file_mapping::swap(file_mapping &other) |
116 { | 129 { |
117 std::swap(m_handle, other.m_handle); | 130 (simple_swap)(m_handle, other.m_handle); |
118 std::swap(m_mode, other.m_mode); | 131 (simple_swap)(m_mode, other.m_mode); |
119 m_filename.swap(other.m_filename); | 132 m_filename.swap(other.m_filename); |
120 } | 133 } |
121 | 134 |
122 inline mapping_handle_t file_mapping::get_mapping_handle() const | 135 inline mapping_handle_t file_mapping::get_mapping_handle() const |
123 { return ipcdetail::mapping_handle_from_file_handle(m_handle); } | 136 { return ipcdetail::mapping_handle_from_file_handle(m_handle); } |
148 } | 161 } |
149 | 162 |
150 inline bool file_mapping::remove(const char *filename) | 163 inline bool file_mapping::remove(const char *filename) |
151 { return ipcdetail::delete_file(filename); } | 164 { return ipcdetail::delete_file(filename); } |
152 | 165 |
153 ///@cond | 166 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) |
154 | 167 |
155 inline void file_mapping::priv_close() | 168 inline void file_mapping::priv_close() |
156 { | 169 { |
157 if(m_handle != ipcdetail::invalid_file()){ | 170 if(m_handle != ipcdetail::invalid_file()){ |
158 ipcdetail::close_file(m_handle); | 171 ipcdetail::close_file(m_handle); |
159 m_handle = ipcdetail::invalid_file(); | 172 m_handle = ipcdetail::invalid_file(); |
160 } | 173 } |
161 } | 174 } |
162 | |
163 ///@endcond | |
164 | 175 |
165 //!A class that stores the name of a file | 176 //!A class that stores the name of a file |
166 //!and tries to remove it in its destructor | 177 //!and tries to remove it in its destructor |
167 //!Useful to remove temporary files in the presence | 178 //!Useful to remove temporary files in the presence |
168 //!of exceptions | 179 //!of exceptions |
176 | 187 |
177 ~remove_file_on_destroy() | 188 ~remove_file_on_destroy() |
178 { ipcdetail::delete_file(m_name); } | 189 { ipcdetail::delete_file(m_name); } |
179 }; | 190 }; |
180 | 191 |
192 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED | |
193 | |
181 } //namespace interprocess { | 194 } //namespace interprocess { |
182 } //namespace boost { | 195 } //namespace boost { |
183 | 196 |
184 #include <boost/interprocess/detail/config_end.hpp> | 197 #include <boost/interprocess/detail/config_end.hpp> |
185 | 198 |