Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:25

0001 //////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga 2009-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_BASIC_GLOBAL_MEMORY_HPP
0012 #define BOOST_INTERPROCESS_BASIC_GLOBAL_MEMORY_HPP
0013 
0014 #ifndef BOOST_CONFIG_HPP
0015 #  include <boost/config.hpp>
0016 #endif
0017 #
0018 #if defined(BOOST_HAS_PRAGMA_ONCE)
0019 #pragma once
0020 #endif
0021 
0022 #include <boost/interprocess/detail/config_begin.hpp>
0023 #include <boost/interprocess/detail/workaround.hpp>
0024 
0025 #include <boost/interprocess/offset_ptr.hpp>
0026 #include <boost/interprocess/sync/spin/mutex.hpp>
0027 #include <boost/interprocess/sync/spin/recursive_mutex.hpp>
0028 #include <boost/interprocess/detail/managed_memory_impl.hpp>
0029 #include <boost/interprocess/detail/managed_open_or_create_impl.hpp>
0030 #include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
0031 #include <boost/interprocess/indexes/iset_index.hpp>
0032 #include <boost/interprocess/creation_tags.hpp>
0033 #include <boost/interprocess/permissions.hpp>
0034 
0035 namespace boost{
0036 namespace interprocess{
0037 namespace ipcdetail{
0038 
0039 struct intermodule_singleton_mutex_family
0040 {
0041    typedef boost::interprocess::ipcdetail::spin_mutex              mutex_type;
0042    typedef boost::interprocess::ipcdetail::spin_recursive_mutex    recursive_mutex_type;
0043 };
0044 
0045 struct intermodule_types
0046 {
0047    //We must use offset_ptr since a loaded DLL can map the singleton holder shared memory
0048    //at a different address than other DLLs or the main executable
0049    typedef rbtree_best_fit<intermodule_singleton_mutex_family, offset_ptr<void> > mem_algo;
0050    template<class Device, bool FileBased>
0051    struct open_or_create
0052    {
0053       typedef managed_open_or_create_impl
0054             <Device, mem_algo::Alignment, FileBased, false> type;
0055    };
0056 };
0057 
0058 //we must implement our own managed shared memory to avoid circular dependencies
0059 template<class Device, bool FileBased>
0060 class basic_managed_global_memory
0061    : public basic_managed_memory_impl
0062       < char
0063       , intermodule_types::mem_algo
0064       , iset_index
0065       , intermodule_types::open_or_create<Device, FileBased>::type::ManagedOpenOrCreateUserOffset
0066       >
0067    , private intermodule_types::open_or_create<Device, FileBased>::type
0068 {
0069    #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0070    typedef typename intermodule_types::template open_or_create<Device, FileBased>::type base2_t;
0071 
0072    typedef basic_managed_memory_impl
0073       < char
0074       , intermodule_types::mem_algo
0075       , iset_index
0076       , base2_t::ManagedOpenOrCreateUserOffset
0077       > base_t;
0078 
0079    typedef create_open_func<base_t>        create_open_func_t;
0080 
0081    basic_managed_global_memory *get_this_pointer()
0082    {  return this;   }
0083 
0084    public:
0085    typedef typename base_t::size_type              size_type;
0086 
0087    private:
0088    typedef typename base_t::char_ptr_holder_t   char_ptr_holder_t;
0089    BOOST_MOVABLE_BUT_NOT_COPYABLE(basic_managed_global_memory)
0090    #endif   //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0091 
0092    public: //functions
0093 
0094    basic_managed_global_memory (open_or_create_t,
0095                               const char *name, size_type size,
0096                               const void *addr = 0, const permissions& perm = permissions())
0097       : base_t()
0098       , base2_t(open_or_create_t(), name, size, read_write, addr,
0099                 create_open_func_t(get_this_pointer(),
0100                 DoOpenOrCreate), perm)
0101    {}
0102 
0103    basic_managed_global_memory (open_only_t , const char* name,
0104                                 const void *addr = 0)
0105       : base_t()
0106       , base2_t(open_only_t(), name, read_write, addr,
0107                 create_open_func_t(get_this_pointer(),
0108                 DoOpen))
0109    {}
0110 };
0111 
0112 
0113 }  //namespace ipcdetail{
0114 }  //namespace interprocess{
0115 }  //namespace boost{
0116 
0117 #include <boost/interprocess/detail/config_end.hpp>
0118 
0119 #endif   //#ifndef BOOST_INTERPROCESS_BASIC_GLOBAL_MEMORY_HPP