Exemple #1
0
   //!can be opened for read-only "read_only" or read-write 
   //!"read_write.
   template<class MemoryMappable>
   mapped_region(const MemoryMappable& mapping
                ,mode_t mode
                ,offset_t offset = 0
                ,std::size_t size = 0
                ,const void *address = 0);

   //!Default constructor. Address and size and offset will be 0.
   //!Does not throw
   mapped_region();

   //!Move constructor. *this will be constructed taking ownership of "other"'s 
   //!region and "other" will be left in default constructor state.
   mapped_region(BOOST_INTERPROCESS_RV_REF(mapped_region) other)
   #if defined (BOOST_INTERPROCESS_WINDOWS)
   :  m_base(0), m_size(0), m_offset(0)
   ,  m_extra_offset(0)
   ,  m_mode(read_only)
   ,  m_file_mapping_hnd(detail::invalid_file())
   #else
   :  m_base(MAP_FAILED), m_size(0), m_offset(0),  m_extra_offset(0), m_mode(read_only), m_is_xsi(false)
   #endif
   {  this->swap(other);   }


   //!Destroys the mapped region.
   //!Does not throw
   ~mapped_region();
Exemple #2
0
    //!can be opened for read-only "read_only" or read-write
    //!"read_write.
    template<class MemoryMappable>
    mapped_region(const MemoryMappable& mapping
                  ,mode_t mode
                  ,offset_t offset = 0
                                     ,std::size_t size = 0
                                             ,const void *address = 0);

    //!Default constructor. Address and size and offset will be 0.
    //!Does not throw
    mapped_region();

    //!Move constructor. *this will be constructed taking ownership of "other"'s
    //!region and "other" will be left in default constructor state.
    mapped_region(BOOST_INTERPROCESS_RV_REF(mapped_region) other);

    //!Destroys the mapped region.
    //!Does not throw
    ~mapped_region();

    //!Move assignment. If *this owns a memory mapped region, it will be
    //!destroyed and it will take ownership of "other"'s memory mapped region.
    mapped_region &operator=(BOOST_INTERPROCESS_RV_REF(mapped_region) other);

    //!Returns the size of the mapping. Note for windows users: If
    //!windows_shared_memory is mapped using 0 as the size, it returns 0
    //!because the size is unknown. Never throws.
    std::size_t get_size() const;

    //!Returns the base address of the mapping.
   //!Tries to create a shared memory object with name "name" and mode "mode", with the
   //!access mode "mode". If the file previously exists, it tries to open it with mode "mode".
   //!Otherwise throws an error.
   windows_shared_memory(open_or_create_t, const char *name, mode_t mode, std::size_t size)
   {  this->priv_open_or_create(detail::DoOpenOrCreate, name, mode, size);  }

   //!Tries to open a shared memory object with name "name", with the access mode "mode". 
   //!If the file does not previously exist, it throws an error.
   windows_shared_memory(open_only_t, const char *name, mode_t mode)
   {  this->priv_open_or_create(detail::DoOpen, name, mode, 0);  }

   //!Moves the ownership of "moved"'s shared memory object to *this. 
   //!After the call, "moved" does not represent any shared memory object. 
   //!Does not throw
   windows_shared_memory(BOOST_INTERPROCESS_RV_REF(windows_shared_memory) moved)
   {  this->swap(moved);   }

   //!Moves the ownership of "moved"'s shared memory to *this.
   //!After the call, "moved" does not represent any shared memory. 
   //!Does not throw
   windows_shared_memory &operator=(BOOST_INTERPROCESS_RV_REF(windows_shared_memory) moved)
   {  
      windows_shared_memory tmp(boost::interprocess::move(moved));
      this->swap(tmp);
      return *this;  
   }

   //!Swaps to shared_memory_objects. Does not throw
   void swap(windows_shared_memory &other);
   //!Default constructor.
   //!Represents an empty xsi_named_mutex.
   xsi_named_mutex();

   //!Tries to create a new XSI-based named mutex with a key obtained from a call to ftok (with path
   //!"path" and id "id"), and permissions "perm".
   //!If the named mutex previously exists, it tries to open it.
   //!Otherwise throws an error.
   xsi_named_mutex(open_or_create_t, const char *path, boost::uint8_t id, int perm = 0666)
   {  this->priv_open_or_create(detail::DoOpenOrCreate, path, id, perm);  }

   //!Moves the ownership of "moved"'s named mutex to *this. 
   //!After the call, "moved" does not represent any named mutex 
   //!Does not throw
   xsi_named_mutex(BOOST_INTERPROCESS_RV_REF(xsi_named_mutex) moved)
   {  this->swap(moved);   }

   //!Moves the ownership of "moved"'s named mutex to *this.
   //!After the call, "moved" does not represent any named mutex. 
   //!Does not throw
   xsi_named_mutex &operator=(BOOST_INTERPROCESS_RV_REF(xsi_named_mutex) moved)
   {  
      xsi_named_mutex tmp(boost::interprocess::move(moved));
      this->swap(tmp);
      return *this;  
   }

   //!Swaps two xsi_named_mutex. Does not throw
   void swap(xsi_named_mutex &other);
   //!Tries to create a shared memory object with name "name" and mode "mode", with the
   //!access mode "mode". If the file previously exists, it tries to open it with mode "mode".
   //!Otherwise throws an error.
   shared_memory_object(open_or_create_t, const char *name, mode_t mode)
   {  this->priv_open_or_create(detail::DoOpenOrCreate, name, mode);  }

   //!Tries to open a shared memory object with name "name", with the access mode "mode". 
   //!If the file does not previously exist, it throws an error.
   shared_memory_object(open_only_t, const char *name, mode_t mode)
   {  this->priv_open_or_create(detail::DoOpen, name, mode);  }

   //!Moves the ownership of "moved"'s shared memory object to *this. 
   //!After the call, "moved" does not represent any shared memory object. 
   //!Does not throw
   shared_memory_object(BOOST_INTERPROCESS_RV_REF(shared_memory_object) moved)
      :  m_handle(file_handle_t(detail::invalid_file()))
   {  this->swap(moved);   }

   //!Moves the ownership of "moved"'s shared memory to *this.
   //!After the call, "moved" does not represent any shared memory. 
   //!Does not throw
   shared_memory_object &operator=(BOOST_INTERPROCESS_RV_REF(shared_memory_object) moved)
   {  
      shared_memory_object tmp(boost::interprocess::move(moved));
      this->swap(tmp);
      return *this;  
   }

   //!Swaps the shared_memory_objects. Does not throw
   void swap(shared_memory_object &moved);
   {}

   //!Connects to a created shared memory and its segment manager
   //!in read-only mode.
   //!This can throw.
   basic_managed_windows_shared_memory
      (open_read_only_t, const char* name, const void *addr = 0)
      : base_t()
      , m_wshm(open_only, name, read_only, addr, 
                create_open_func_t(get_this_pointer(), detail::DoOpen))
   {}

   //!Moves the ownership of "moved"'s managed memory to *this.
   //!Does not throw
   basic_managed_windows_shared_memory
      (BOOST_INTERPROCESS_RV_REF(basic_managed_windows_shared_memory) moved)
   {  this->swap(moved);   }

   //!Moves the ownership of "moved"'s managed memory to *this.
   //!Does not throw
   basic_managed_windows_shared_memory &operator=(BOOST_INTERPROCESS_RV_REF(basic_managed_windows_shared_memory) moved)
   {
      basic_managed_windows_shared_memory tmp(boost::interprocess::move(moved));
      this->swap(tmp);
      return *this;
   }

   //!Destroys *this and indicates that the calling process is finished using
   //!the resource. All mapped regions are still valid after
   //!destruction. When all mapped regions and basic_managed_windows_shared_memory
   //!objects referring the shared memory are destroyed, the
   //!
   //!Effects: Constructs a unique_ptr which owns the pointer which u owns
   //!(if any). If the deleter is not a reference type, it is move constructed
   //!from u's deleter, otherwise the reference is copy constructed from u's deleter.
   //!
   //!After the construction, u no longer owns a pointer.
   //![ Note: The deleter constructor can be implemented with
   //!   boost::interprocess::forward<D>. -end note ]
   //!
   //!Postconditions: get() == value u.get() had before the construction.
   //!get_deleter() returns a reference to the internally stored deleter which
   //!was constructed from u.get_deleter(). If D is a reference type then get_-
   //!deleter() and u.get_deleter() both reference the same lvalue deleter.
   //!
   //!Throws: nothing.
   unique_ptr(BOOST_INTERPROCESS_RV_REF(unique_ptr) u)
      : ptr_(u.release(), boost::interprocess::forward<D>(u.get_deleter()))
   {}

   //!Requires: If D is not a reference type, construction of the deleter
   //!D from an rvalue of type E must be well formed
   //!and not throw an exception. If D is a reference type, then E must be
   //!the same type as D (diagnostic required). unique_ptr<U, E>::pointer
   //!must be implicitly convertible to pointer.
   //!
   //!Effects: Constructs a unique_ptr which owns the pointer which u owns
   //!(if any). If the deleter is not a reference
   //!type, it is move constructed from u's deleter, otherwise the reference
   //!is copy constructed from u's deleter.
   //!
   //!After the construction, u no longer owns a pointer.
Exemple #8
0
   {  this->priv_open_or_create(detail::DoCreate, key, perm, size);  }

   //!Opens an existing shared memory with identifier 'key' or creates a new XSI shared memory from
   //!identifier 'key', with size "size" and permissions "perm".
   xsi_shared_memory(open_or_create_t, const xsi_key &key, std::size_t size, const permissions& perm = permissions())
   {  this->priv_open_or_create(detail::DoOpenOrCreate, key, perm, size);  }

   //!Tries to open a XSI shared memory with identifier 'key'
   //!If the shared memory does not previously exist, it throws an error.
   xsi_shared_memory(open_only_t, const xsi_key &key)
   {  this->priv_open_or_create(detail::DoOpen, key, permissions(), 0);  }

   //!Moves the ownership of "moved"'s shared memory object to *this. 
   //!After the call, "moved" does not represent any shared memory object. 
   //!Does not throw
   xsi_shared_memory(BOOST_INTERPROCESS_RV_REF(xsi_shared_memory) moved)
      : m_shmid(-1)
   {  this->swap(moved);   }

   //!Moves the ownership of "moved"'s shared memory to *this.
   //!After the call, "moved" does not represent any shared memory. 
   //!Does not throw
   xsi_shared_memory &operator=(BOOST_INTERPROCESS_RV_REF(xsi_shared_memory) moved)
   {  
      xsi_shared_memory tmp(boost::interprocess::move(moved));
      this->swap(tmp);
      return *this;  
   }

   //!Swaps two xsi_shared_memorys. Does not throw
   void swap(xsi_shared_memory &other);
      }
   }

   //!Creates and places the segment manager. This can throw
   basic_managed_external_buffer
      (open_only_t, void *addr, std::size_t size)
   {
      //Check if alignment is correct
      assert((0 == (((std::size_t)addr) & (AllocationAlgorithm::Alignment - std::size_t(1u)))));
      if(!base_t::open_impl(addr, size)){
         throw interprocess_exception();
      }
   }

   //!Moves the ownership of "moved"'s managed memory to *this. Does not throw
   basic_managed_external_buffer(BOOST_INTERPROCESS_RV_REF(basic_managed_external_buffer) moved)
   {
      this->swap(moved);
   }

   //!Moves the ownership of "moved"'s managed memory to *this. Does not throw
   basic_managed_external_buffer &operator=(BOOST_INTERPROCESS_RV_REF(basic_managed_external_buffer) moved)
   {
      basic_managed_external_buffer tmp(boost::interprocess::move(moved));
      this->swap(tmp);
      return *this;
   }

   void grow(std::size_t extra_bytes)
   {  base_t::grow(extra_bytes);   }
    file_wrapper(open_or_create_t, const char *name, mode_t mode, const permissions &perm  = permissions())
    {
        this->priv_open_or_create(detail::DoOpenOrCreate, name, mode, perm);
    }

    //!Tries to open a file with name "name", with the access mode "mode".
    //!If the file does not previously exist, it throws an error.
    file_wrapper(open_only_t, const char *name, mode_t mode)
    {
        this->priv_open_or_create(detail::DoOpen, name, mode, permissions());
    }

    //!Moves the ownership of "moved"'s file to *this.
    //!After the call, "moved" does not represent any file.
    //!Does not throw
    file_wrapper(BOOST_INTERPROCESS_RV_REF(file_wrapper) moved)
        :  m_handle(file_handle_t(detail::invalid_file()))
    {
        this->swap(moved);
    }

    //!Moves the ownership of "moved"'s file to *this.
    //!After the call, "moved" does not represent any file.
    //!Does not throw
    file_wrapper &operator=(BOOST_INTERPROCESS_RV_REF(file_wrapper) moved)
    {
        file_wrapper tmp(boost::interprocess::move(moved));
        this->swap(tmp);
        return *this;
    }