Boost logo

Boost-Commit :

From: igaztanaga_at_[hidden]
Date: 2008-05-23 18:34:44


Author: igaztanaga
Date: 2008-05-23 18:34:43 EDT (Fri, 23 May 2008)
New Revision: 45698
URL: http://svn.boost.org/trac/boost/changeset/45698

Log:
#1912: some copy edits on boost.intrusive
#1932: move semantics for shared objects
#1635: Incomplete include guard in boost/intrusive
Text files modified:
   trunk/boost/interprocess/creation_tags.hpp | 22 ++++++++++++++--
   trunk/boost/interprocess/errors.hpp | 4 +-
   trunk/boost/interprocess/file_mapping.hpp | 19 ++++++++++++-
   trunk/boost/interprocess/interprocess_fwd.hpp | 12 ++++----
   trunk/boost/interprocess/managed_heap_memory.hpp | 26 +++++++++++++++++--
   trunk/boost/interprocess/managed_mapped_file.hpp | 53 +++++++++++++++++++++++++++++++--------
   trunk/boost/interprocess/managed_shared_memory.hpp | 50 ++++++++++++++++++++++++++++++-------
   trunk/boost/interprocess/managed_windows_shared_memory.hpp | 46 +++++++++++++++++++++++++++++-----
   trunk/boost/interprocess/mapped_region.hpp | 10 ++++++
   trunk/boost/interprocess/segment_manager.hpp | 12 ++++----
   trunk/boost/interprocess/shared_memory_object.hpp | 18 ++++++++++++-
   11 files changed, 219 insertions(+), 53 deletions(-)

Modified: trunk/boost/interprocess/creation_tags.hpp
==============================================================================
--- trunk/boost/interprocess/creation_tags.hpp (original)
+++ trunk/boost/interprocess/creation_tags.hpp 2008-05-23 18:34:43 EDT (Fri, 23 May 2008)
@@ -26,20 +26,36 @@
 struct open_only_t {};
 
 //!Tag to indicate that the resource must
+//!be only opened for reading
+struct open_read_only_t {};
+
+//!Tag to indicate that the resource must
+//!be only opened for reading
+struct open_copy_on_write_t {};
+
+//!Tag to indicate that the resource must
 //!be created. If already created, it must be opened.
 struct open_or_create_t {};
 
 //!Value to indicate that the resource must
 //!be only created
-static const create_only_t create_only = create_only_t();
+static const create_only_t create_only = create_only_t();
 
 //!Value to indicate that the resource must
 //!be only opened
-static const open_only_t open_only = open_only_t();
+static const open_only_t open_only = open_only_t();
+
+//!Value to indicate that the resource must
+//!be only opened for reading
+static const open_read_only_t open_read_only = open_read_only_t();
 
 //!Value to indicate that the resource must
 //!be created. If already created, it must be opened.
-static const open_or_create_t open_or_create = open_or_create_t();
+static const open_or_create_t open_or_create = open_or_create_t();
+
+//!Value to indicate that the resource must
+//!be only opened for reading
+static const open_copy_on_write_t open_copy_on_write = open_copy_on_write_t();
 
 namespace detail {
 

Modified: trunk/boost/interprocess/errors.hpp
==============================================================================
--- trunk/boost/interprocess/errors.hpp (original)
+++ trunk/boost/interprocess/errors.hpp 2008-05-23 18:34:43 EDT (Fri, 23 May 2008)
@@ -10,8 +10,8 @@
 //
 //////////////////////////////////////////////////////////////////////////////
 //
-// Copyright (c) 2002 Beman Dawes
-// Copyright (c) 2001 Dietmar Kuehl
+// Copyright (C) 2002 Beman Dawes
+// Copyright (C) 2001 Dietmar Kuehl
 // Use, modification, and distribution is subject to the Boost Software
 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
 // at http://www.boost.org/LICENSE_1_0.txt)

Modified: trunk/boost/interprocess/file_mapping.hpp
==============================================================================
--- trunk/boost/interprocess/file_mapping.hpp (original)
+++ trunk/boost/interprocess/file_mapping.hpp 2008-05-23 18:34:43 EDT (Fri, 23 May 2008)
@@ -19,6 +19,7 @@
 #include <boost/interprocess/detail/utilities.hpp>
 #include <boost/interprocess/creation_tags.hpp>
 #include <boost/interprocess/detail/os_file_functions.hpp>
+#include <boost/interprocess/detail/move.hpp>
 #include <string> //std::string
 #include <cstdio> //std::remove
 #include <string>
@@ -55,10 +56,12 @@
    //!After the call, "moved" does not represent any shared memory object.
    //!Does not throw
    #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
- file_mapping(detail::moved_object<file_mapping> &moved)
+ file_mapping(detail::moved_object<file_mapping> moved)
+ : m_handle(file_handle_t(detail::invalid_file()))
    { this->swap(moved.get()); }
    #else
    file_mapping(file_mapping &&moved)
+ : m_handle(file_handle_t(detail::invalid_file()))
    { this->swap(moved); }
    #endif
 
@@ -67,7 +70,7 @@
    //!Does not throw
    #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    file_mapping &operator=
- (detail::moved_object<file_mapping> &moved)
+ (detail::moved_object<file_mapping> moved)
    {
       file_mapping tmp(moved);
       this->swap(tmp);
@@ -165,6 +168,18 @@
    }
 }
 
+///@cond
+
+//!Trait class to detect if a type is
+//!movable
+template<>
+struct is_movable<file_mapping>
+{
+ enum { value = true };
+};
+
+///@endcond
+
 } //namespace interprocess {
 } //namespace boost {
 

Modified: trunk/boost/interprocess/interprocess_fwd.hpp
==============================================================================
--- trunk/boost/interprocess/interprocess_fwd.hpp (original)
+++ trunk/boost/interprocess/interprocess_fwd.hpp 2008-05-23 18:34:43 EDT (Fri, 23 May 2008)
@@ -120,26 +120,26 @@
 template<class T, class SegmentManager>
 class allocator;
 
-template<class T, class SegmentManager, std::size_t NodesPerChunk = 64>
+template<class T, class SegmentManager, std::size_t NodesPerBlock = 64>
 class node_allocator;
 
-template<class T, class SegmentManager, std::size_t NodesPerChunk = 64>
+template<class T, class SegmentManager, std::size_t NodesPerBlock = 64>
 class private_node_allocator;
 
-template<class T, class SegmentManager, std::size_t NodesPerChunk = 64>
+template<class T, class SegmentManager, std::size_t NodesPerBlock = 64>
 class cached_node_allocator;
 
-template<class T, class SegmentManager, std::size_t NodesPerChunk = 64, std::size_t MaxFreeChunks = 2
+template<class T, class SegmentManager, std::size_t NodesPerBlock = 64, std::size_t MaxFreeBlocks = 2
          , unsigned char OverheadPercent = 5
>
 class adaptive_pool;
 
-template<class T, class SegmentManager, std::size_t NodesPerChunk = 64, std::size_t MaxFreeChunks = 2
+template<class T, class SegmentManager, std::size_t NodesPerBlock = 64, std::size_t MaxFreeBlocks = 2
          , unsigned char OverheadPercent = 5
>
 class private_adaptive_pool;
 
-template<class T, class SegmentManager, std::size_t NodesPerChunk = 64, std::size_t MaxFreeChunks = 2
+template<class T, class SegmentManager, std::size_t NodesPerBlock = 64, std::size_t MaxFreeBlocks = 2
          , unsigned char OverheadPercent = 5
>
 class cached_adaptive_pool;

Modified: trunk/boost/interprocess/managed_heap_memory.hpp
==============================================================================
--- trunk/boost/interprocess/managed_heap_memory.hpp (original)
+++ trunk/boost/interprocess/managed_heap_memory.hpp 2008-05-23 18:34:43 EDT (Fri, 23 May 2008)
@@ -50,7 +50,8 @@
 
    public: //functions
 
- //!Constructor. Never throws.
+ //!Default constructor. Does nothing.
+ //!Useful in combination with move semantics
    basic_managed_heap_memory(){}
 
    //!Destructor. Liberates the heap memory holding the managed data.
@@ -72,7 +73,7 @@
    //!Moves the ownership of "moved"'s managed memory to *this. Does not throw
    #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    basic_managed_heap_memory
- (detail::moved_object<basic_managed_heap_memory> &moved)
+ (detail::moved_object<basic_managed_heap_memory> moved)
    { this->swap(moved.get()); }
    #else
    basic_managed_heap_memory(basic_managed_heap_memory &&moved)
@@ -82,7 +83,7 @@
    //!Moves the ownership of "moved"'s managed memory to *this. Does not throw
    #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    basic_managed_heap_memory &operator=
- (detail::moved_object<basic_managed_heap_memory> &moved)
+ (detail::moved_object<basic_managed_heap_memory> moved)
    { this->swap(moved.get()); return *this; }
    #else
    basic_managed_heap_memory &operator=
@@ -139,6 +140,25 @@
    /// @endcond
 };
 
+///@cond
+
+//!Trait class to detect if a type is
+//!movable
+template
+ <
+ class CharType,
+ class AllocationAlgorithm,
+ template<class IndexConfig> class IndexType
+ >
+struct is_movable<basic_managed_heap_memory
+ <CharType, AllocationAlgorithm, IndexType>
+>
+{
+ static const bool value = true;
+};
+
+///@endcond
+
 } //namespace interprocess {
 
 } //namespace boost {

Modified: trunk/boost/interprocess/managed_mapped_file.hpp
==============================================================================
--- trunk/boost/interprocess/managed_mapped_file.hpp (original)
+++ trunk/boost/interprocess/managed_mapped_file.hpp 2008-05-23 18:34:43 EDT (Fri, 23 May 2008)
@@ -23,14 +23,11 @@
 #include <boost/interprocess/detail/file_wrapper.hpp>
 #include <boost/interprocess/detail/move.hpp>
 
-//!\file
-//!Describes a named shared memory object allocation user class.
-
 namespace boost {
 namespace interprocess {
 
-//!A basic shared memory named object creation class. Initializes the
-//!shared memory segment. Inherits all basic functionality from
+//!A basic mapped file named object creation class. Initializes the
+//!mapped file. Inherits all basic functionality from
 //!basic_managed_memory_impl<CharType, AllocationAlgorithm, IndexType>
 template
       <
@@ -61,7 +58,12 @@
 
    public: //functions
 
- //!Creates shared memory and creates and places the segment manager.
+ //!Creates mapped file and creates and places the segment manager.
+ //!This can throw.
+ basic_managed_mapped_file()
+ {}
+
+ //!Creates mapped file and creates and places the segment manager.
    //!This can throw.
    basic_managed_mapped_file(create_only_t create_only, const char *name,
                              std::size_t size, const void *addr = 0)
@@ -69,7 +71,7 @@
                 create_open_func_t(get_this_pointer(), detail::DoCreate))
    {}
 
- //!Creates shared memory and creates and places the segment manager if
+ //!Creates mapped file and creates and places the segment manager if
    //!segment was not created. If segment was created it connects to the
    //!segment.
    //!This can throw.
@@ -81,8 +83,8 @@
                 detail::DoOpenOrCreate))
    {}
 
- //!Connects to a created shared memory and it's the segment manager.
- //!Never throws.
+ //!Connects to a created mapped file and its segment manager.
+ //!This can throw.
    basic_managed_mapped_file (open_only_t open_only, const char* name,
                               const void *addr = 0)
       : m_mfile(open_only, name, read_write, addr,
@@ -90,11 +92,21 @@
                 detail::DoOpen))
    {}
 
+ //!Connects to a created mapped file and its segment manager
+ //!in copy_on_write mode.
+ //!This can throw.
+ basic_managed_mapped_file (open_copy_on_write_t, const char* name,
+ const void *addr = 0)
+ : m_mfile(open_only, name, copy_on_write, addr,
+ create_open_func_t(get_this_pointer(),
+ detail::DoOpen))
+ {}
+
    //!Moves the ownership of "moved"'s managed memory to *this.
    //!Does not throw
    #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    basic_managed_mapped_file
- (detail::moved_object<basic_managed_mapped_file> &moved)
+ (detail::moved_object<basic_managed_mapped_file> moved)
    { this->swap(moved.get()); }
    #else
    basic_managed_mapped_file(basic_managed_mapped_file &&moved)
@@ -105,7 +117,7 @@
    //!Does not throw
    #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    basic_managed_mapped_file &operator=
- (detail::moved_object<basic_managed_mapped_file> &moved)
+ (detail::moved_object<basic_managed_mapped_file> moved)
    { this->swap(moved.get()); return *this; }
    #else
    basic_managed_mapped_file &operator=(basic_managed_mapped_file &&moved)
@@ -161,6 +173,25 @@
    /// @endcond
 };
 
+///@cond
+
+//!Trait class to detect if a type is
+//!movable
+template
+ <
+ class CharType,
+ class AllocationAlgorithm,
+ template<class IndexConfig> class IndexType
+ >
+struct is_movable<basic_managed_mapped_file
+ <CharType, AllocationAlgorithm, IndexType>
+>
+{
+ static const bool value = true;
+};
+
+///@endcond
+
 } //namespace interprocess {
 
 } //namespace boost {

Modified: trunk/boost/interprocess/managed_shared_memory.hpp
==============================================================================
--- trunk/boost/interprocess/managed_shared_memory.hpp (original)
+++ trunk/boost/interprocess/managed_shared_memory.hpp 2008-05-23 18:34:43 EDT (Fri, 23 May 2008)
@@ -23,9 +23,6 @@
 #include <boost/interprocess/shared_memory_object.hpp>
 #include <boost/interprocess/creation_tags.hpp>
 
-//!\file
-//!Describes a named shared memory object allocation user class.
-
 namespace boost {
 
 namespace interprocess {
@@ -58,8 +55,6 @@
 
    typedef detail::create_open_func<base_t> create_open_func_t;
 
- basic_managed_shared_memory();
-
    basic_managed_shared_memory *get_this_pointer()
    { return this; }
    /// @endcond
@@ -75,6 +70,11 @@
    ~basic_managed_shared_memory()
    {}
 
+ //!Default constructor. Does nothing.
+ //!Useful in combination with move semantics
+ basic_managed_shared_memory()
+ {}
+
    //!Creates shared memory and creates and places the segment manager.
    //!This can throw.
    basic_managed_shared_memory(create_only_t create_only, const char *name,
@@ -97,10 +97,21 @@
                 detail::DoOpenOrCreate))
    {}
 
- //!Connects to a created shared memory and it's the segment manager.
- //!Never throws.
+ //!Connects to a created shared memory and its segment manager.
+ //!in copy_on_write mode.
+ //!This can throw.
+ basic_managed_shared_memory (open_copy_on_write_t, const char* name,
+ const void *addr = 0)
+ : base_t()
+ , base2_t(open_only, name, copy_on_write, addr,
+ create_open_func_t(get_this_pointer(),
+ detail::DoOpen))
+ {}
+
+ //!Connects to a created shared memory and its segment manager.
+ //!This can throw.
    basic_managed_shared_memory (open_only_t open_only, const char* name,
- const void *addr = 0)
+ const void *addr = 0)
       : base_t()
       , base2_t(open_only, name, read_write, addr,
                 create_open_func_t(get_this_pointer(),
@@ -111,7 +122,7 @@
    //!Does not throw
    #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    basic_managed_shared_memory
- (detail::moved_object<basic_managed_shared_memory> &moved)
+ (detail::moved_object<basic_managed_shared_memory> moved)
    { this->swap(moved.get()); }
    #else
    basic_managed_shared_memory(basic_managed_shared_memory &&moved)
@@ -122,7 +133,7 @@
    //!Does not throw
    #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    basic_managed_shared_memory &operator=
- (detail::moved_object<basic_managed_shared_memory> &moved)
+ (detail::moved_object<basic_managed_shared_memory> moved)
    { this->swap(moved.get()); return *this; }
    #else
    basic_managed_shared_memory &operator=(basic_managed_shared_memory &&moved)
@@ -159,6 +170,25 @@
    }
 };
 
+///@cond
+
+//!Trait class to detect if a type is
+//!movable
+template
+ <
+ class CharType,
+ class AllocationAlgorithm,
+ template<class IndexConfig> class IndexType
+ >
+struct is_movable<basic_managed_shared_memory
+ <CharType, AllocationAlgorithm, IndexType>
+>
+{
+ static const bool value = true;
+};
+
+///@endcond
+
 } //namespace interprocess {
 } //namespace boost {
 

Modified: trunk/boost/interprocess/managed_windows_shared_memory.hpp
==============================================================================
--- trunk/boost/interprocess/managed_windows_shared_memory.hpp (original)
+++ trunk/boost/interprocess/managed_windows_shared_memory.hpp 2008-05-23 18:34:43 EDT (Fri, 23 May 2008)
@@ -23,9 +23,6 @@
 #include <boost/interprocess/windows_shared_memory.hpp>
 #include <boost/interprocess/detail/move.hpp>
 
-//!\file
-//!Describes a named shared memory object allocation user class.
-
 namespace boost {
 namespace interprocess {
 
@@ -63,6 +60,12 @@
    /// @endcond
 
    public: //functions
+
+ //!Default constructor. Does nothing.
+ //!Useful in combination with move semantics
+ basic_managed_windows_shared_memory()
+ {}
+
    //!Creates shared memory and creates and places the segment manager.
    //!This can throw.
    basic_managed_windows_shared_memory
@@ -85,8 +88,8 @@
                 detail::DoOpenOrCreate))
    {}
 
- //!Connects to a created shared memory and it's the segment manager.
- //!Never throws.
+ //!Connects to a created shared memory and its segment manager.
+ //!This can throw.
    basic_managed_windows_shared_memory (open_only_t open_only, const char* name,
                               const void *addr = 0)
       : m_wshm(open_only, name, read_write, addr,
@@ -94,11 +97,21 @@
                 detail::DoOpen))
    {}
 
+ //!Connects to a created shared memory and its segment manager
+ //!in copy_on_write mode.
+ //!This can throw.
+ basic_managed_windows_shared_memory (open_copy_on_write_t, const char* name,
+ const void *addr = 0)
+ : m_wshm(open_only, name, copy_on_write, addr,
+ create_open_func_t(get_this_pointer(),
+ detail::DoOpen))
+ {}
+
    //!Moves the ownership of "moved"'s managed memory to *this.
    //!Does not throw
    #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    basic_managed_windows_shared_memory
- (detail::moved_object<basic_managed_windows_shared_memory> &moved)
+ (detail::moved_object<basic_managed_windows_shared_memory> moved)
    { this->swap(moved.get()); }
    #else
    basic_managed_windows_shared_memory(basic_managed_windows_shared_memory &&moved)
@@ -109,7 +122,7 @@
    //!Does not throw
    #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    basic_managed_windows_shared_memory &operator=
- (detail::moved_object<basic_managed_windows_shared_memory> &moved)
+ (detail::moved_object<basic_managed_windows_shared_memory> moved)
    { this->swap(moved.get()); return *this; }
    #else
    basic_managed_windows_shared_memory &operator=
@@ -138,6 +151,25 @@
    /// @endcond
 };
 
+///@cond
+
+//!Trait class to detect if a type is
+//!movable
+template
+ <
+ class CharType,
+ class AllocationAlgorithm,
+ template<class IndexConfig> class IndexType
+ >
+struct is_movable<basic_managed_windows_shared_memory
+ <CharType, AllocationAlgorithm, IndexType>
+>
+{
+ static const bool value = true;
+};
+
+///@endcond
+
 } //namespace interprocess {
 } //namespace boost {
 

Modified: trunk/boost/interprocess/mapped_region.hpp
==============================================================================
--- trunk/boost/interprocess/mapped_region.hpp (original)
+++ trunk/boost/interprocess/mapped_region.hpp 2008-05-23 18:34:43 EDT (Fri, 23 May 2008)
@@ -444,7 +444,7 @@
       break;
 
       case copy_on_write:
- prot |= PROT_READ;
+ prot |= (PROT_WRITE | PROT_READ);
          flags |= MAP_PRIVATE;
       break;
    
@@ -553,6 +553,14 @@
    bool operator()(void *, std::size_t , bool) const
       { return true; }
 };
+
+//!Trait class to detect if a type is
+//!movable
+template<>
+struct is_movable<mapped_region>
+{
+ enum { value = true };
+};
 /// @endcond
 
 } //namespace interprocess {

Modified: trunk/boost/interprocess/segment_manager.hpp
==============================================================================
--- trunk/boost/interprocess/segment_manager.hpp (original)
+++ trunk/boost/interprocess/segment_manager.hpp 2008-05-23 18:34:43 EDT (Fri, 23 May 2008)
@@ -1118,7 +1118,7 @@
 
       //Initialize the node value_eraser to erase inserted node
       //if something goes wrong
- detail::value_eraser<index_type> value_eraser(index, it);
+ value_eraser<index_type> v_eraser(index, it);
       
       //Avoid constructions if constructor is trivial
       //Build scoped ptr to avoid leaks with constructor exception
@@ -1130,8 +1130,8 @@
 
       //All constructors successful, we don't want to release memory
       mem.release();
- //Release node value_eraser since construction was successful
- value_eraser.release();
+ //Release node v_eraser since construction was successful
+ v_eraser.release();
       return ptr;
    }
 
@@ -1204,7 +1204,7 @@
       }
       //Initialize the node value_eraser to erase inserted node
       //if something goes wrong
- detail::value_eraser<index_type> value_eraser(index, it);
+ value_eraser<index_type> v_eraser(index, it);
 
       //Allocates buffer for name + data, this can throw (it hurts)
       void *buffer_ptr;
@@ -1260,8 +1260,8 @@
       //All constructors successful, we don't want to release memory
       mem.release();
 
- //Release node value_eraser since construction was successful
- value_eraser.release();
+ //Release node v_eraser since construction was successful
+ v_eraser.release();
       return ptr;
    }
 

Modified: trunk/boost/interprocess/shared_memory_object.hpp
==============================================================================
--- trunk/boost/interprocess/shared_memory_object.hpp (original)
+++ trunk/boost/interprocess/shared_memory_object.hpp 2008-05-23 18:34:43 EDT (Fri, 23 May 2008)
@@ -76,10 +76,12 @@
    //!Does not throw
    #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    shared_memory_object
- (detail::moved_object<shared_memory_object> &moved)
+ (const detail::moved_object<shared_memory_object> moved)
+ : m_handle(file_handle_t(detail::invalid_file()))
    { this->swap(moved.get()); }
    #else
    shared_memory_object(shared_memory_object &&moved)
+ : m_handle(file_handle_t(detail::invalid_file()))
    { this->swap(moved); }
    #endif
 
@@ -88,7 +90,7 @@
    //!Does not throw
    #ifndef BOOST_INTERPROCESS_RVALUE_REFERENCE
    shared_memory_object &operator=
- (detail::moved_object<shared_memory_object> &moved)
+ (detail::moved_object<shared_memory_object> moved)
    {
       shared_memory_object tmp(moved);
       this->swap(tmp);
@@ -341,6 +343,18 @@
 
 #endif
 
+///@cond
+
+//!Trait class to detect if a type is
+//!movable
+template<>
+struct is_movable<shared_memory_object>
+{
+ enum { value = true };
+};
+
+///@endcond
+
 } //namespace interprocess {
 } //namespace boost {
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk