interprocess_fwd.hpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2005-2012. 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)
  6. //
  7. // See http://www.boost.org/libs/interprocess for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. #ifndef BOOST_INTERPROCESS_FWD_HPP
  11. #define BOOST_INTERPROCESS_FWD_HPP
  12. #ifndef BOOST_CONFIG_HPP
  13. # include <boost/config.hpp>
  14. #endif
  15. #ifndef BOOST_CSTDINT_HPP
  16. # include <boost/cstdint.hpp>
  17. #endif
  18. #
  19. #if defined(BOOST_HAS_PRAGMA_ONCE)
  20. # pragma once
  21. #endif
  22. #include <boost/interprocess/detail/std_fwd.hpp>
  23. //! \file
  24. //! This header file forward declares the basic interprocess types:
  25. //! - boost::interprocess::offset_ptr;
  26. //! - boost::interprocess::permissions;
  27. //! - boost::interprocess::mapped_region;
  28. //! - boost::interprocess::file_mapping;
  29. //! - boost::interprocess::shared_memory_object;
  30. //! - boost::interprocess::windows_shared_memory;
  31. //! - boost::interprocess::xsi_shared_memory;
  32. //!
  33. //! The following synchronization mechanisms and locks:
  34. //! - boost::interprocess::null_mutex;
  35. //! - boost::interprocess::interprocess_mutex;
  36. //! - boost::interprocess::interprocess_recursive_mutex;
  37. //! - boost::interprocess::interprocess_semaphore;
  38. //! - boost::interprocess::named_mutex;
  39. //! - boost::interprocess::named_recursive_mutex;
  40. //! - boost::interprocess::named_semaphore;
  41. //! - boost::interprocess::interprocess_sharable_mutex;
  42. //! - boost::interprocess::interprocess_condition;
  43. //! - boost::interprocess::scoped_lock;
  44. //! - boost::interprocess::sharable_lock;
  45. //! - boost::interprocess::upgradable_lock;
  46. //!
  47. //! The following mutex families:
  48. //! - boost::interprocess::mutex_family;
  49. //! - boost::interprocess::null_mutex_family;
  50. //!
  51. //! The following allocators:
  52. //! - boost::interprocess::allocator;
  53. //! - boost::interprocess::node_allocator;
  54. //! - boost::interprocess::private_node_allocator;
  55. //! - boost::interprocess::cached_node_allocator;
  56. //! - boost::interprocess::adaptive_pool;
  57. //! - boost::interprocess::private_adaptive_pool;
  58. //! - boost::interprocess::cached_adaptive_pool;
  59. //!
  60. //! The following allocation algorithms:
  61. //! - boost::interprocess::simple_seq_fit;
  62. //! - boost::interprocess::rbtree_best_fit;
  63. //!
  64. //! The following index types:
  65. //! - boost::interprocess::flat_map_index;
  66. //! - boost::interprocess::iset_index;
  67. //! - boost::interprocess::iunordered_set_index;
  68. //! - boost::interprocess::map_index;
  69. //! - boost::interprocess::null_index;
  70. //! - boost::interprocess::unordered_map_index;
  71. //!
  72. //! The following managed memory types:
  73. //! - boost::interprocess::segment_manager;
  74. //! - boost::interprocess::basic_managed_external_buffer
  75. //! - boost::interprocess::managed_external_buffer
  76. //! - boost::interprocess::wmanaged_external_buffer
  77. //! - boost::interprocess::basic_managed_shared_memory
  78. //! - boost::interprocess::managed_shared_memory
  79. //! - boost::interprocess::wmanaged_shared_memory
  80. //! - boost::interprocess::basic_managed_windows_shared_memory
  81. //! - boost::interprocess::managed_windows_shared_memory
  82. //! - boost::interprocess::wmanaged_windows_shared_memory
  83. //! - boost::interprocess::basic_managed_xsi_shared_memory
  84. //! - boost::interprocess::managed_xsi_shared_memory
  85. //! - boost::interprocess::wmanaged_xsi_shared_memory
  86. //! - boost::interprocess::fixed_managed_shared_memory
  87. //! - boost::interprocess::wfixed_managed_shared_memory
  88. //! - boost::interprocess::basic_managed_heap_memory
  89. //! - boost::interprocess::managed_heap_memory
  90. //! - boost::interprocess::wmanaged_heap_memory
  91. //! - boost::interprocess::basic_managed_mapped_file
  92. //! - boost::interprocess::managed_mapped_file
  93. //! - boost::interprocess::wmanaged_mapped_file
  94. //!
  95. //! The following exception types:
  96. //! - boost::interprocess::interprocess_exception
  97. //! - boost::interprocess::lock_exception
  98. //! - boost::interprocess::bad_alloc
  99. //!
  100. //! The following stream types:
  101. //! - boost::interprocess::basic_bufferbuf
  102. //! - boost::interprocess::basic_ibufferstream
  103. //! - boost::interprocess::basic_obufferstream
  104. //! - boost::interprocess::basic_bufferstream
  105. //! - boost::interprocess::basic_vectorbuf
  106. //! - boost::interprocess::basic_ivectorstream
  107. //! - boost::interprocess::basic_ovectorstream
  108. //! - boost::interprocess::basic_vectorstream
  109. //!
  110. //! The following smart pointer types:
  111. //! - boost::interprocess::scoped_ptr
  112. //! - boost::interprocess::intrusive_ptr
  113. //! - boost::interprocess::shared_ptr
  114. //! - boost::interprocess::weak_ptr
  115. //!
  116. //! The following interprocess communication types:
  117. //! - boost::interprocess::message_queue_t;
  118. //! - boost::interprocess::message_queue;
  119. #include <boost/interprocess/detail/config_begin.hpp>
  120. #include <boost/interprocess/detail/workaround.hpp>
  121. #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
  122. #include <cstddef>
  123. //////////////////////////////////////////////////////////////////////////////
  124. // Standard predeclarations
  125. //////////////////////////////////////////////////////////////////////////////
  126. namespace boost{ namespace intrusive{ } }
  127. namespace boost{ namespace interprocess{ namespace bi = boost::intrusive; } }
  128. namespace boost { namespace interprocess {
  129. //////////////////////////////////////////////////////////////////////////////
  130. // permissions
  131. //////////////////////////////////////////////////////////////////////////////
  132. class permissions;
  133. //////////////////////////////////////////////////////////////////////////////
  134. // shared_memory
  135. //////////////////////////////////////////////////////////////////////////////
  136. class shared_memory_object;
  137. #if defined (BOOST_INTERPROCESS_WINDOWS)
  138. class windows_shared_memory;
  139. #endif //#if defined (BOOST_INTERPROCESS_WINDOWS)
  140. #if defined(BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS)
  141. class xsi_shared_memory;
  142. #endif //#if defined (BOOST_INTERPROCESS_WINDOWS)
  143. //////////////////////////////////////////////////////////////////////////////
  144. // file mapping / mapped region
  145. //////////////////////////////////////////////////////////////////////////////
  146. class file_mapping;
  147. class mapped_region;
  148. //////////////////////////////////////////////////////////////////////////////
  149. // Mutexes
  150. //////////////////////////////////////////////////////////////////////////////
  151. class null_mutex;
  152. class interprocess_mutex;
  153. class interprocess_recursive_mutex;
  154. class named_mutex;
  155. class named_recursive_mutex;
  156. class interprocess_semaphore;
  157. class named_semaphore;
  158. //////////////////////////////////////////////////////////////////////////////
  159. // Mutex families
  160. //////////////////////////////////////////////////////////////////////////////
  161. struct mutex_family;
  162. struct null_mutex_family;
  163. //////////////////////////////////////////////////////////////////////////////
  164. // Other synchronization classes
  165. //////////////////////////////////////////////////////////////////////////////
  166. class interprocess_sharable_mutex;
  167. class interprocess_condition;
  168. //////////////////////////////////////////////////////////////////////////////
  169. // Locks
  170. //////////////////////////////////////////////////////////////////////////////
  171. template <class Mutex>
  172. class scoped_lock;
  173. template <class SharableMutex>
  174. class sharable_lock;
  175. template <class UpgradableMutex>
  176. class upgradable_lock;
  177. //////////////////////////////////////////////////////////////////////////////
  178. // STL compatible allocators
  179. //////////////////////////////////////////////////////////////////////////////
  180. template<class T, class SegmentManager>
  181. class allocator;
  182. template<class T, class SegmentManager, std::size_t NodesPerBlock = 64>
  183. class node_allocator;
  184. template<class T, class SegmentManager, std::size_t NodesPerBlock = 64>
  185. class private_node_allocator;
  186. template<class T, class SegmentManager, std::size_t NodesPerBlock = 64>
  187. class cached_node_allocator;
  188. template< class T, class SegmentManager, std::size_t NodesPerBlock = 64
  189. , std::size_t MaxFreeBlocks = 2, unsigned char OverheadPercent = 5 >
  190. class adaptive_pool;
  191. template< class T, class SegmentManager, std::size_t NodesPerBlock = 64
  192. , std::size_t MaxFreeBlocks = 2, unsigned char OverheadPercent = 5 >
  193. class private_adaptive_pool;
  194. template< class T, class SegmentManager, std::size_t NodesPerBlock = 64
  195. , std::size_t MaxFreeBlocks = 2, unsigned char OverheadPercent = 5 >
  196. class cached_adaptive_pool;
  197. //////////////////////////////////////////////////////////////////////////////
  198. // offset_ptr
  199. //////////////////////////////////////////////////////////////////////////////
  200. static const std::size_t offset_type_alignment = 0;
  201. #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
  202. # ifdef BOOST_HAS_INTPTR_T
  203. using ::boost::uintptr_t;
  204. # else
  205. typedef std::size_t uintptr_t;
  206. # endif
  207. #endif
  208. template < class T, class DifferenceType = std::ptrdiff_t
  209. , class OffsetType = uintptr_t, std::size_t Alignment = offset_type_alignment>
  210. class offset_ptr;
  211. //////////////////////////////////////////////////////////////////////////////
  212. // Memory allocation algorithms
  213. //////////////////////////////////////////////////////////////////////////////
  214. //Single segment memory allocation algorithms
  215. template<class MutexFamily, class VoidMutex = offset_ptr<void> >
  216. class simple_seq_fit;
  217. template<class MutexFamily, class VoidMutex = offset_ptr<void>, std::size_t MemAlignment = 0>
  218. class rbtree_best_fit;
  219. //////////////////////////////////////////////////////////////////////////////
  220. // Index Types
  221. //////////////////////////////////////////////////////////////////////////////
  222. template<class IndexConfig> class flat_map_index;
  223. template<class IndexConfig> class iset_index;
  224. template<class IndexConfig> class iunordered_set_index;
  225. template<class IndexConfig> class map_index;
  226. template<class IndexConfig> class null_index;
  227. template<class IndexConfig> class unordered_map_index;
  228. //////////////////////////////////////////////////////////////////////////////
  229. // Segment manager
  230. //////////////////////////////////////////////////////////////////////////////
  231. template <class CharType
  232. ,class MemoryAlgorithm
  233. ,template<class IndexConfig> class IndexType>
  234. class segment_manager;
  235. //////////////////////////////////////////////////////////////////////////////
  236. // External buffer managed memory classes
  237. //////////////////////////////////////////////////////////////////////////////
  238. template <class CharType
  239. ,class MemoryAlgorithm
  240. ,template<class IndexConfig> class IndexType>
  241. class basic_managed_external_buffer;
  242. typedef basic_managed_external_buffer
  243. <char
  244. ,rbtree_best_fit<null_mutex_family>
  245. ,iset_index>
  246. managed_external_buffer;
  247. typedef basic_managed_external_buffer
  248. <wchar_t
  249. ,rbtree_best_fit<null_mutex_family>
  250. ,iset_index>
  251. wmanaged_external_buffer;
  252. //////////////////////////////////////////////////////////////////////////////
  253. // managed memory classes
  254. //////////////////////////////////////////////////////////////////////////////
  255. template <class CharType
  256. ,class MemoryAlgorithm
  257. ,template<class IndexConfig> class IndexType>
  258. class basic_managed_shared_memory;
  259. typedef basic_managed_shared_memory
  260. <char
  261. ,rbtree_best_fit<mutex_family>
  262. ,iset_index>
  263. managed_shared_memory;
  264. typedef basic_managed_shared_memory
  265. <wchar_t
  266. ,rbtree_best_fit<mutex_family>
  267. ,iset_index>
  268. wmanaged_shared_memory;
  269. //////////////////////////////////////////////////////////////////////////////
  270. // Windows shared memory managed memory classes
  271. //////////////////////////////////////////////////////////////////////////////
  272. #if defined (BOOST_INTERPROCESS_WINDOWS)
  273. template <class CharType
  274. ,class MemoryAlgorithm
  275. ,template<class IndexConfig> class IndexType>
  276. class basic_managed_windows_shared_memory;
  277. typedef basic_managed_windows_shared_memory
  278. <char
  279. ,rbtree_best_fit<mutex_family>
  280. ,iset_index>
  281. managed_windows_shared_memory;
  282. typedef basic_managed_windows_shared_memory
  283. <wchar_t
  284. ,rbtree_best_fit<mutex_family>
  285. ,iset_index>
  286. wmanaged_windows_shared_memory;
  287. #endif //#if defined (BOOST_INTERPROCESS_WINDOWS)
  288. #if defined(BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS)
  289. template <class CharType
  290. ,class MemoryAlgorithm
  291. ,template<class IndexConfig> class IndexType>
  292. class basic_managed_xsi_shared_memory;
  293. typedef basic_managed_xsi_shared_memory
  294. <char
  295. ,rbtree_best_fit<mutex_family>
  296. ,iset_index>
  297. managed_xsi_shared_memory;
  298. typedef basic_managed_xsi_shared_memory
  299. <wchar_t
  300. ,rbtree_best_fit<mutex_family>
  301. ,iset_index>
  302. wmanaged_xsi_shared_memory;
  303. #endif //#if defined(BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS)
  304. //////////////////////////////////////////////////////////////////////////////
  305. // Fixed address shared memory
  306. //////////////////////////////////////////////////////////////////////////////
  307. typedef basic_managed_shared_memory
  308. <char
  309. ,rbtree_best_fit<mutex_family, void*>
  310. ,iset_index>
  311. fixed_managed_shared_memory;
  312. typedef basic_managed_shared_memory
  313. <wchar_t
  314. ,rbtree_best_fit<mutex_family, void*>
  315. ,iset_index>
  316. wfixed_managed_shared_memory;
  317. //////////////////////////////////////////////////////////////////////////////
  318. // Heap memory managed memory classes
  319. //////////////////////////////////////////////////////////////////////////////
  320. template
  321. <class CharType
  322. ,class MemoryAlgorithm
  323. ,template<class IndexConfig> class IndexType>
  324. class basic_managed_heap_memory;
  325. typedef basic_managed_heap_memory
  326. <char
  327. ,rbtree_best_fit<null_mutex_family>
  328. ,iset_index>
  329. managed_heap_memory;
  330. typedef basic_managed_heap_memory
  331. <wchar_t
  332. ,rbtree_best_fit<null_mutex_family>
  333. ,iset_index>
  334. wmanaged_heap_memory;
  335. //////////////////////////////////////////////////////////////////////////////
  336. // Mapped file managed memory classes
  337. //////////////////////////////////////////////////////////////////////////////
  338. template
  339. <class CharType
  340. ,class MemoryAlgorithm
  341. ,template<class IndexConfig> class IndexType>
  342. class basic_managed_mapped_file;
  343. typedef basic_managed_mapped_file
  344. <char
  345. ,rbtree_best_fit<mutex_family>
  346. ,iset_index>
  347. managed_mapped_file;
  348. typedef basic_managed_mapped_file
  349. <wchar_t
  350. ,rbtree_best_fit<mutex_family>
  351. ,iset_index>
  352. wmanaged_mapped_file;
  353. //////////////////////////////////////////////////////////////////////////////
  354. // Exceptions
  355. //////////////////////////////////////////////////////////////////////////////
  356. class interprocess_exception;
  357. class lock_exception;
  358. class bad_alloc;
  359. //////////////////////////////////////////////////////////////////////////////
  360. // Bufferstream
  361. //////////////////////////////////////////////////////////////////////////////
  362. //bufferstream
  363. template <class CharT
  364. ,class CharTraits = std::char_traits<CharT> >
  365. class basic_bufferbuf;
  366. template <class CharT
  367. ,class CharTraits = std::char_traits<CharT> >
  368. class basic_ibufferstream;
  369. template <class CharT
  370. ,class CharTraits = std::char_traits<CharT> >
  371. class basic_obufferstream;
  372. template <class CharT
  373. ,class CharTraits = std::char_traits<CharT> >
  374. class basic_bufferstream;
  375. //////////////////////////////////////////////////////////////////////////////
  376. // Vectorstream
  377. //////////////////////////////////////////////////////////////////////////////
  378. template <class CharVector
  379. ,class CharTraits = std::char_traits<typename CharVector::value_type> >
  380. class basic_vectorbuf;
  381. template <class CharVector
  382. ,class CharTraits = std::char_traits<typename CharVector::value_type> >
  383. class basic_ivectorstream;
  384. template <class CharVector
  385. ,class CharTraits = std::char_traits<typename CharVector::value_type> >
  386. class basic_ovectorstream;
  387. template <class CharVector
  388. ,class CharTraits = std::char_traits<typename CharVector::value_type> >
  389. class basic_vectorstream;
  390. //////////////////////////////////////////////////////////////////////////////
  391. // Smart pointers
  392. //////////////////////////////////////////////////////////////////////////////
  393. template<class T, class Deleter>
  394. class scoped_ptr;
  395. template<class T, class VoidPointer>
  396. class intrusive_ptr;
  397. template<class T, class VoidAllocator, class Deleter>
  398. class shared_ptr;
  399. template<class T, class VoidAllocator, class Deleter>
  400. class weak_ptr;
  401. //////////////////////////////////////////////////////////////////////////////
  402. // IPC
  403. //////////////////////////////////////////////////////////////////////////////
  404. template<class VoidPointer>
  405. class message_queue_t;
  406. typedef message_queue_t<offset_ptr<void> > message_queue;
  407. }} //namespace boost { namespace interprocess {
  408. #endif //#if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
  409. #include <boost/interprocess/detail/config_end.hpp>
  410. #endif //#ifndef BOOST_INTERPROCESS_FWD_HPP