mirror of
https://github.com/boostorg/interprocess.git
synced 2026-01-19 04:12:13 +00:00
Implemented N1780 proposal to LWG issue 233: Insertion hints in associative containers in interprocess boost::interprocess::multiset and boost::interprocess::multimap class.
Source breaking: A shared memory object is now used including shared_memory_object.hpp header instead of shared memory.hpp. ABI breaking: Changed global mutex when initializing managed shared memory and memory mapped files. This change tries to minimize deadlocks. Source breaking: Changed shared memory, memory mapped files and mapped region's open mode to a single boost::interprocess::mode_t type. Added extra WIN32_LEAN_AND_MEAN before including DateTime headers to avoid socket redefinition errors when using Interprocess and Asio in windows. ABI breaking: mapped_region constructor no longer requires classes derived from memory_mappable, but classes the fulfill the MemoryMappable concept. Added in-place reallocation capabilities to basic_string. ABI breaking: Reimplemented and optimized small string optimization. The narrow string class has zero byte overhead with an internal 11 byte buffer in 32 systems! Added move semantics to containers. Experimental and not documented yet. Improves performance when using containers of containers. ABI breaking: End nodes of node containers (list, slist, map/set) are now embedded in the containers instead of allocated using the allocator. This allows no-throw move-constructors and improves performance. ABI breaking: slist and list containers now have constant-time size() function. The size of the container is added as a member. [SVN r35618]
This commit is contained in:
@@ -10,7 +10,8 @@
|
||||
|
||||
#include <boost/interprocess/detail/config_begin.hpp>
|
||||
#include <boost/interprocess/detail/workaround.hpp>
|
||||
#include <boost/interprocess/shared_memory.hpp>
|
||||
#include <boost/interprocess/shared_memory_object.hpp>
|
||||
#include <boost/interprocess/detail/managed_open_or_create_impl.hpp>
|
||||
#include <boost/interprocess/exceptions.hpp>
|
||||
#include "named_creation_template.hpp"
|
||||
#include <cstring> //for strcmp, memset
|
||||
@@ -19,9 +20,9 @@
|
||||
static const std::size_t ShmSize = 1000;
|
||||
static const char * ShmName = "shared_memory";
|
||||
|
||||
struct shared_memory_eraser
|
||||
struct eraser
|
||||
{
|
||||
~shared_memory_eraser()
|
||||
~eraser()
|
||||
{
|
||||
boost::interprocess::shared_memory_object::remove(ShmName);
|
||||
}
|
||||
@@ -30,22 +31,24 @@ struct shared_memory_eraser
|
||||
//This wrapper is necessary to have a common constructor
|
||||
//in generic named_creation_template functions
|
||||
class shared_memory_creation_test_wrapper
|
||||
: public boost::interprocess::shared_memory
|
||||
: public eraser
|
||||
, public boost::interprocess::detail::managed_open_or_create_impl
|
||||
<boost::interprocess::shared_memory_object>
|
||||
{
|
||||
typedef boost::interprocess::detail::managed_open_or_create_impl
|
||||
<boost::interprocess::shared_memory_object> shared_memory;
|
||||
|
||||
public:
|
||||
shared_memory_creation_test_wrapper(boost::interprocess::detail::create_only_t)
|
||||
: boost::interprocess::shared_memory
|
||||
(boost::interprocess::create_only, ShmName, ShmSize)
|
||||
: shared_memory(boost::interprocess::create_only, ShmName, ShmSize)
|
||||
{}
|
||||
|
||||
shared_memory_creation_test_wrapper(boost::interprocess::detail::open_only_t)
|
||||
: boost::interprocess::shared_memory
|
||||
(boost::interprocess::open_only, ShmName)
|
||||
: shared_memory(boost::interprocess::open_only, ShmName)
|
||||
{}
|
||||
|
||||
shared_memory_creation_test_wrapper(boost::interprocess::detail::open_or_create_t)
|
||||
: boost::interprocess::shared_memory
|
||||
(boost::interprocess::open_or_create, ShmName, ShmSize)
|
||||
: shared_memory(boost::interprocess::open_or_create, ShmName, ShmSize)
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -53,6 +56,8 @@ class shared_memory_creation_test_wrapper
|
||||
int main ()
|
||||
{
|
||||
using namespace boost::interprocess;
|
||||
typedef detail::managed_open_or_create_impl<shared_memory_object> shared_memory;
|
||||
|
||||
try{
|
||||
shared_memory_object::remove(ShmName);
|
||||
test::test_named_creation<shared_memory_creation_test_wrapper>();
|
||||
@@ -62,17 +67,13 @@ int main ()
|
||||
shared_memory_object::remove(ShmName);
|
||||
shared_memory shm1(create_only, ShmName, ShmSize);
|
||||
|
||||
//Compare size
|
||||
if(shm1.get_size() != ShmSize)
|
||||
return 1;
|
||||
|
||||
//Compare name
|
||||
if(std::strcmp(shm1.get_name(), ShmName) != 0){
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Overwrite all memory
|
||||
std::memset(shm1.get_address(), 0, ShmSize);
|
||||
std::memset(shm1.get_address(), 0, shm1.get_size());
|
||||
}
|
||||
}
|
||||
catch(std::exception &ex){
|
||||
@@ -82,4 +83,3 @@ int main ()
|
||||
}
|
||||
|
||||
#include <boost/interprocess/detail/config_end.hpp>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user