Chris@16: ////////////////////////////////////////////////////////////////////////////// Chris@16: // Chris@16: // (C) Copyright Ion Gaztanaga 2009-2012. Distributed under the Boost Chris@16: // Software License, Version 1.0. (See accompanying file Chris@16: // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // See http://www.boost.org/libs/interprocess for documentation. Chris@16: // Chris@16: ////////////////////////////////////////////////////////////////////////////// Chris@16: Chris@16: #ifndef BOOST_INTERPROCESS_BASIC_GLOBAL_MEMORY_HPP Chris@16: #define BOOST_INTERPROCESS_BASIC_GLOBAL_MEMORY_HPP Chris@16: Chris@101: #ifndef BOOST_CONFIG_HPP Chris@101: # include Chris@101: #endif Chris@101: # Chris@101: #if defined(BOOST_HAS_PRAGMA_ONCE) Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost{ Chris@16: namespace interprocess{ Chris@16: namespace ipcdetail{ Chris@16: Chris@16: struct intermodule_singleton_mutex_family Chris@16: { Chris@16: typedef boost::interprocess::ipcdetail::spin_mutex mutex_type; Chris@16: typedef boost::interprocess::ipcdetail::spin_recursive_mutex recursive_mutex_type; Chris@16: }; Chris@16: Chris@16: struct intermodule_types Chris@16: { Chris@16: //We must use offset_ptr since a loaded DLL can map the singleton holder shared memory Chris@16: //at a different address than other DLLs or the main executable Chris@16: typedef rbtree_best_fit > mem_algo; Chris@16: template Chris@16: struct open_or_create Chris@16: { Chris@16: typedef managed_open_or_create_impl Chris@16: type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: //we must implement our own managed shared memory to avoid circular dependencies Chris@16: template Chris@16: class basic_managed_global_memory Chris@16: : public basic_managed_memory_impl Chris@16: < char Chris@16: , intermodule_types::mem_algo Chris@16: , iset_index Chris@16: , intermodule_types::open_or_create::type::ManagedOpenOrCreateUserOffset Chris@16: > Chris@16: , private intermodule_types::open_or_create::type Chris@16: { Chris@101: #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) Chris@16: typedef typename intermodule_types::template open_or_create::type base2_t; Chris@16: Chris@16: typedef basic_managed_memory_impl Chris@16: < char Chris@16: , intermodule_types::mem_algo Chris@16: , iset_index Chris@16: , base2_t::ManagedOpenOrCreateUserOffset Chris@16: > base_t; Chris@16: Chris@16: typedef create_open_func create_open_func_t; Chris@16: Chris@16: basic_managed_global_memory *get_this_pointer() Chris@16: { return this; } Chris@16: Chris@16: public: Chris@16: typedef typename base_t::size_type size_type; Chris@16: Chris@16: private: Chris@16: typedef typename base_t::char_ptr_holder_t char_ptr_holder_t; Chris@16: BOOST_MOVABLE_BUT_NOT_COPYABLE(basic_managed_global_memory) Chris@101: #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED Chris@16: Chris@16: public: //functions Chris@16: Chris@16: basic_managed_global_memory (open_or_create_t open_or_create, Chris@16: const char *name, size_type size, Chris@16: const void *addr = 0, const permissions& perm = permissions()) Chris@16: : base_t() Chris@16: , base2_t(open_or_create, name, size, read_write, addr, Chris@16: create_open_func_t(get_this_pointer(), Chris@16: DoOpenOrCreate), perm) Chris@16: {} Chris@16: Chris@16: basic_managed_global_memory (open_only_t open_only, const char* name, Chris@16: const void *addr = 0) Chris@16: : base_t() Chris@16: , base2_t(open_only, name, read_write, addr, Chris@16: create_open_func_t(get_this_pointer(), Chris@16: DoOpen)) Chris@16: {} Chris@16: }; Chris@16: Chris@16: Chris@16: } //namespace ipcdetail{ Chris@16: } //namespace interprocess{ Chris@16: } //namespace boost{ Chris@16: Chris@16: #include Chris@16: Chris@16: #endif //#ifndef BOOST_INTERPROCESS_BASIC_GLOBAL_MEMORY_HPP