* Fixed GCC -Wshadow warnings.

*  Experimental multiple allocation interface improved and changed again. Still unstable.
*  Replaced deprecated BOOST_NO_XXXX with newer BOOST_NO_CXX11_XXX macros.
*  [*ABI breaking]: changed node pool allocators internals for improved efficiency.

[SVN r81521]
This commit is contained in:
Ion Gaztañaga
2012-11-24 21:14:02 +00:00
parent c79c37183d
commit 9c175fa83f
29 changed files with 269 additions and 149 deletions

View File

@@ -8,7 +8,7 @@
[library Boost.Interprocess
[quickbook 1.4]
[authors [Gaztanaga, Ion]]
[copyright 2005- 2011 Ion Gaztanaga]
[copyright 2005-2012 Ion Gaztanaga]
[id interprocess]
[dirname interprocess]
[purpose Interprocess communication utilities]
@@ -3898,6 +3898,8 @@ Here is a small example showing how aligned allocation is used:
[section:managed_memory_segment_multiple_allocations Multiple allocation functions]
[caution This feature is experimental, interface and ABI are unstable]
If an application needs to allocate a lot of memory buffers but it needs
to deallocate them independently, the application is normally forced to loop
calling `allocate()`. Managed memory segments offer an alternative function
@@ -3917,33 +3919,26 @@ There are 2 types of `allocate_many` functions:
[c++]
//!Allocates n_elements of elem_size bytes.
multiallocation_iterator allocate_many(std::size_t elem_size, std::size_t min_elements, std::size_t preferred_elements, std::size_t &received_elements);
//!Allocates n_elements of elem_bytes bytes.
//!Throws bad_alloc on failure. chain.size() is not increased on failure.
void allocate_many(size_type elem_bytes, size_type n_elements, multiallocation_chain &chain);
//!Allocates n_elements, each one of elem_sizes[i] bytes.
multiallocation_iterator allocate_many(const std::size_t *elem_sizes, std::size_t n_elements);
//!Allocates n_elements, each one of element_lengths[i]*sizeof_element bytes.
//!Throws bad_alloc on failure. chain.size() is not increased on failure.
void allocate_many(const size_type *element_lengths, size_type n_elements, size_type sizeof_element, multiallocation_chain &chain);
//!Allocates n_elements of elem_size bytes. No throwing version.
multiallocation_iterator allocate_many(std::size_t elem_size, std::size_t min_elements, std::size_t preferred_elements, std::size_t &received_elements, std::nothrow_t nothrow);
//!Allocates n_elements of elem_bytes bytes.
//!Non-throwing version. chain.size() is not increased on failure.
void allocate_many(std::nothrow_t, size_type elem_bytes, size_type n_elements, multiallocation_chain &chain);
//!Allocates n_elements, each one of elem_sizes[i] bytes. No throwing version.
multiallocation_iterator allocate_many(const std::size_t *elem_sizes, std::size_t n_elements, std::nothrow_t nothrow);
//!Allocates n_elements, each one of
//!element_lengths[i]*sizeof_element bytes.
//!Non-throwing version. chain.size() is not increased on failure.
void allocate_many(std::nothrow_t, const size_type *elem_sizes, size_type n_elements, size_type sizeof_element, multiallocation_chain &chain);
All functions return a `multiallocation iterator` that can be used to obtain
pointers to memory the user can overwrite. A `multiallocation_iterator`:
* Becomes invalidated if the memory is pointing to is deallocated or
the next iterators (which previously were reachable with `operator++`)
become invalid.
* Returned from `allocate_many` can be checked in a boolean expression to
know if the allocation has been successful.
* A default constructed `multiallocation iterator` indicates
both an invalid iterator and the "end" iterator.
* Dereferencing an iterator (`operator *()`) returns a `char &`
referencing the first byte user can overwrite
in the memory buffer.
* The iterator category depends on the memory allocation algorithm,
but it's at least a forward iterator.
//!Deallocates all elements contained in chain.
//!Never throws.
void deallocate_many(multiallocation_chain &chain);
Here is a small example showing all this functionality:
@@ -6716,16 +6711,25 @@ thank them:
[section:release_notes Release Notes]
[section:release_notes_boost_1_53_00 Boost 1.53 Release]
* Fixed GCC -Wshadow warnings.
* Experimental multiple allocation interface improved and changed again. Still unstable.
* Replaced deprecated BOOST_NO_XXXX with newer BOOST_NO_CXX11_XXX macros.
* [*ABI breaking]: changed node pool allocators internals for improved efficiency.
[endsect]
[section:release_notes_boost_1_52_00 Boost 1.52 Release]
* Added `shrink_by` and `advise` functions in `mapped_region`.
* [*ABI breaking]Reimplemented `message_queue` with a circular buffer index (the
* [*ABI breaking:] Reimplemented `message_queue` with a circular buffer index (the
old behavior used an ordered array, leading to excessive copies). This
should greatly increase performance but breaks ABI. Old behaviour/ABI can be used
undefining macro `BOOST_INTERPROCESS_MSG_QUEUE_CIRCULAR_INDEX` in `boost/interprocess/detail/workaround.hpp`
* Improved `message_queue` insertion time avoiding priority search for common cases
(both array and circular buffer configurations).
* Implemented `sharable_mutex` and `interproces_condition_any`.
* Implemented `interproces_sharable_mutex` and `interproces_condition_any`.
* Improved `offset_ptr` performance.
* Added integer overflow checks.

View File

@@ -49,6 +49,9 @@ int main ()
const int NumMsg = 100;
int extracted_data [NumMsg];
//<-
(void)extracted_data;
//->
//Extract the data
for(int i = 0; i < NumMsg; ++i){

View File

@@ -25,12 +25,14 @@ int main()
//Define file names
//<-
#if 1
std::string managed_file(boost::interprocess::ipcdetail::get_temporary_path());
managed_file += "/"; managed_file += test::get_process_id_name();
const char *ManagedFile = managed_file.c_str();
std::string managed_file2(boost::interprocess::ipcdetail::get_temporary_path());
managed_file2 += "/"; managed_file2 += test::get_process_id_name(); managed_file2 += "_2";
const char *ManagedFile2 = managed_file2.c_str();
const char *ManagedFile = 0;
const char *ManagedFile2 = 0;
std::string managed_file_name(boost::interprocess::ipcdetail::get_temporary_path());
managed_file_name += "/"; managed_file_name += test::get_process_id_name();
ManagedFile = managed_file_name.c_str();
std::string managed_file2_name(boost::interprocess::ipcdetail::get_temporary_path());
managed_file2_name += "/"; managed_file2_name += test::get_process_id_name(); managed_file2_name += "_2";
ManagedFile2 = managed_file2_name.c_str();
#else
//->
const char *ManagedFile = "MyManagedFile";

View File

@@ -54,7 +54,8 @@ int main()
//->
//Allocate 16 elements of 100 bytes in a single call. Non-throwing version.
multiallocation_chain chain(managed_shm.allocate_many(100, 16, std::nothrow));
multiallocation_chain chain;
managed_shm.allocate_many(std::nothrow, 100, 16, chain);
//Check if the memory allocation was successful
if(chain.empty()) return 1;
@@ -82,8 +83,8 @@ int main()
for(std::size_t i = 0; i < 10; ++i)
sizes[i] = i*3;
chain = managed_shm.allocate_many(sizes, 10);
managed_shm.deallocate_many(boost::move(chain));
managed_shm.allocate_many(sizes, 10, 1, chain);
managed_shm.deallocate_many(chain);
return 0;
}
//]

View File

@@ -14,10 +14,17 @@
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/containers/string.hpp>
//<-
//Shield against external warnings
#include <boost/interprocess/detail/config_external_begin.hpp>
//->
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>
//<-
#include <boost/interprocess/detail/config_external_end.hpp>
#include "../test/get_process_id_name.hpp"
//->

View File

@@ -13,9 +13,21 @@
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
//<-
//Shield against external warnings
#include <boost/interprocess/detail/config_external_begin.hpp>
//->
#include <boost/unordered_map.hpp> //boost::unordered_map
//<-
#include <boost/interprocess/detail/config_external_end.hpp>
#include "../test/get_process_id_name.hpp"
//->
#include <functional> //std::equal_to
#include <boost/functional/hash.hpp> //boost::hash
//<-
#include "../test/get_process_id_name.hpp"
//->

View File

@@ -81,7 +81,7 @@
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="0"/>
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool

View File

@@ -82,7 +82,7 @@
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="0"/>
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool

View File

@@ -487,6 +487,12 @@
<File
RelativePath="..\..\..\..\boost\interprocess\detail\config_end.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\interprocess\detail\config_external_begin.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\interprocess\detail\config_external_end.hpp">
</File>
<File
RelativePath="..\..\..\..\boost\interprocess\detail\file_locking_helpers.hpp">
</File>

View File

@@ -74,6 +74,7 @@
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories="../../../.."
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
RuntimeLibrary="2"
@@ -82,7 +83,7 @@
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="0"/>
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool

View File

@@ -72,6 +72,7 @@
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="3"
AdditionalIncludeDirectories="../../../.."
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
RuntimeLibrary="2"
@@ -80,7 +81,7 @@
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="0"/>
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool

View File

@@ -72,7 +72,7 @@
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
Optimization="3"
InlineFunctionExpansion="0"
AdditionalIncludeDirectories="../../../.."
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"

View File

@@ -80,7 +80,7 @@
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="0"/>
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool

View File

@@ -70,8 +70,8 @@ template <typename F, typename T>
class binder
{
public:
binder(const F& func, const T& param)
: func(func), param(param) { }
binder(const F& f, const T& p)
: func(f), param(p) { }
void operator()() const { func(param); }
private:

View File

@@ -144,8 +144,7 @@ bool do_test()
/*try*/{
//Compare several shared memory deque operations with std::deque
int i;
for(i = 0; i < max*50; ++i){
for(int i = 0; i < max*50; ++i){
IntType move_me(i);
shmdeque->insert(shmdeque->end(), boost::move(move_me));
stddeque->insert(stddeque->end(), i);
@@ -157,7 +156,7 @@ bool do_test()
shmdeque->clear();
stddeque->clear();
for(i = 0; i < max*50; ++i){
for(int i = 0; i < max*50; ++i){
IntType move_me(i);
shmdeque->push_back(boost::move(move_me));
stddeque->push_back(i);
@@ -169,7 +168,7 @@ bool do_test()
shmdeque->clear();
stddeque->clear();
for(i = 0; i < max*50; ++i){
for(int i = 0; i < max*50; ++i){
IntType move_me(i);
shmdeque->push_front(boost::move(move_me));
stddeque->push_front(i);
@@ -241,7 +240,7 @@ bool do_test()
if(!test::CheckEqualContainers(shmdeque, stddeque)) return false;
for(i = 0; i < max; ++i){
for(int i = 0; i < max; ++i){
IntType move_me(i);
shmdeque->insert(shmdeque->begin(), boost::move(move_me));
stddeque->insert(stddeque->begin(), i);

View File

@@ -66,13 +66,16 @@ class expand_bwd_test_allocator
typedef boost::interprocess::version_type<expand_bwd_test_allocator, 2> version;
//Dummy multiallocation chain
struct multiallocation_chain{};
template<class T2>
struct rebind
{ typedef expand_bwd_test_allocator<T2> other; };
//!Constructor from the segment manager. Never throws
expand_bwd_test_allocator(T *buffer, size_type size, difference_type offset)
: mp_buffer(buffer), m_size(size)
expand_bwd_test_allocator(T *buf, size_type sz, difference_type offset)
: mp_buffer(buf), m_size(sz)
, m_offset(offset), m_allocations(0){ }
//!Constructor from other expand_bwd_test_allocator. Never throws

View File

@@ -130,15 +130,15 @@ bool test_arithmetic()
//ptr++
penew = p0;
for(int j = 0; j != NumValues; ++j){
pint_t p = penew;
if(p != penew++)
pint_t pnew_copy = penew;
if(pnew_copy != penew++)
return false;
}
//ptr--
p0 = pe;
for(int j = 0; j != NumValues; ++j){
pint_t p = p0;
if(p != p0--)
pint_t p0_copy = p0;
if(p0_copy != p0--)
return false;
}

View File

@@ -46,10 +46,10 @@ struct file_destroyer
class mapped_file_creation_test_wrapper
: public file_destroyer
, public boost::interprocess::ipcdetail::managed_open_or_create_impl
<boost::interprocess::ipcdetail::file_wrapper>
<boost::interprocess::ipcdetail::file_wrapper, 0, true, false>
{
typedef boost::interprocess::ipcdetail::managed_open_or_create_impl
<boost::interprocess::ipcdetail::file_wrapper> mapped_file;
<boost::interprocess::ipcdetail::file_wrapper, 0, true, false> mapped_file;
public:
mapped_file_creation_test_wrapper(boost::interprocess::create_only_t)
: mapped_file(boost::interprocess::create_only, get_filename().c_str(), FileSize, read_write, 0, permissions())
@@ -67,7 +67,7 @@ class mapped_file_creation_test_wrapper
int main ()
{
typedef boost::interprocess::ipcdetail::managed_open_or_create_impl
<boost::interprocess::ipcdetail::file_wrapper> mapped_file;
<boost::interprocess::ipcdetail::file_wrapper, 0, true, false> mapped_file;
file_mapping::remove(get_filename().c_str());
test::test_named_creation<mapped_file_creation_test_wrapper>();

View File

@@ -23,7 +23,7 @@
using namespace boost::interprocess;
const int memsize = 16384;
const int Memsize = 16384;
const char *const shMemName = test::get_process_id_name();
int test_simple_seq_fit()
@@ -37,7 +37,7 @@ int test_simple_seq_fit()
//Create shared memory
shared_memory_object::remove(shMemName);
my_managed_shared_memory segment(create_only, shMemName, memsize);
my_managed_shared_memory segment(create_only, shMemName, Memsize);
//Now take the segment manager and launch memory test
if(!test::test_all_allocation(*segment.get_segment_manager())){
@@ -58,7 +58,7 @@ int test_rbtree_best_fit()
//Create shared memory
shared_memory_object::remove(shMemName);
my_managed_shared_memory segment(create_only, shMemName, memsize);
my_managed_shared_memory segment(create_only, shMemName, Memsize);
//Now take the segment manager and launch memory test
if(!test::test_all_allocation(*segment.get_segment_manager())){

View File

@@ -673,7 +673,8 @@ bool test_many_equal_allocation(Allocator &a)
typedef typename Allocator::multiallocation_chain multiallocation_chain;
std::vector<void*> buffers;
for(int i = 0; true; ++i){
multiallocation_chain chain(a.allocate_many(i+1, (i+1)*2, std::nothrow));
multiallocation_chain chain;
a.allocate_many(std::nothrow, i+1, (i+1)*2, chain);
if(chain.empty())
break;
@@ -782,7 +783,8 @@ bool test_many_different_allocation(Allocator &a)
std::vector<void*> buffers;
for(int i = 0; true; ++i){
multiallocation_chain chain(a.allocate_many(requested_sizes, ArraySize, 1, std::nothrow));
multiallocation_chain chain;
a.allocate_many(std::nothrow, requested_sizes, ArraySize, 1, chain);
if(chain.empty())
break;
typename multiallocation_chain::size_type n = chain.size();
@@ -850,6 +852,8 @@ bool test_many_different_allocation(Allocator &a)
template<class Allocator>
bool test_many_deallocation(Allocator &a)
{
typedef typename Allocator::multiallocation_chain multiallocation_chain;
typedef typename Allocator::multiallocation_chain multiallocation_chain;
const std::size_t ArraySize = 11;
vector<multiallocation_chain> buffers;
@@ -861,13 +865,14 @@ bool test_many_deallocation(Allocator &a)
{
for(int i = 0; true; ++i){
multiallocation_chain chain = a.allocate_many(requested_sizes, ArraySize, 1, std::nothrow);
multiallocation_chain chain;
a.allocate_many(std::nothrow, requested_sizes, ArraySize, 1, chain);
if(chain.empty())
break;
buffers.push_back(boost::move(chain));
}
for(int i = 0, max = (int)buffers.size(); i != max; ++i){
a.deallocate_many(boost::move(buffers[i]));
a.deallocate_many(buffers[i]);
}
buffers.clear();
bool ok = free_memory == a.get_free_memory() &&
@@ -877,13 +882,14 @@ bool test_many_deallocation(Allocator &a)
{
for(int i = 0; true; ++i){
multiallocation_chain chain(a.allocate_many(i*4, ArraySize, std::nothrow));
multiallocation_chain chain;
a.allocate_many(std::nothrow, i*4, ArraySize, chain);
if(chain.empty())
break;
buffers.push_back(boost::move(chain));
}
for(int i = 0, max = (int)buffers.size(); i != max; ++i){
a.deallocate_many(boost::move(buffers[i]));
a.deallocate_many(buffers[i]);
}
buffers.clear();

View File

@@ -21,10 +21,19 @@
#include <boost/interprocess/containers/string.hpp>
//<-
//Shield against external warnings
#include <boost/interprocess/detail/config_external_begin.hpp>
//->
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>
//<-
#include <boost/interprocess/detail/config_external_end.hpp>
//->
using namespace boost::interprocess;
namespace bmi = boost::multi_index;

View File

@@ -134,8 +134,8 @@ bool test_named_iterators(ManagedMemory &m)
}
for(; named_beg != named_end; ++named_beg){
const char_type *name = named_beg->name();
aux_str = name;
const char_type *name_str = named_beg->name();
aux_str = name_str;
if(names.find(aux_str) == names.end()){
return 1;
}
@@ -144,7 +144,7 @@ bool test_named_iterators(ManagedMemory &m)
return 1;
}
const void *found_value = m.template find<char>(name).first;
const void *found_value = m.template find<char>(name_str).first;
if(found_value == 0)
return false;

View File

@@ -208,15 +208,15 @@ bool test_arithmetic()
//ptr++
penew = p0;
for(int j = 0; j != NumValues; ++j){
pint_t p = penew;
if(p != penew++)
pint_t p_new_copy = penew;
if(p_new_copy != penew++)
return false;
}
//ptr--
p0 = pe;
for(int j = 0; j != NumValues; ++j){
pint_t p = p0;
if(p != p0--)
pint_t p0_copy = p0;
if(p0_copy != p0--)
return false;
}
@@ -290,3 +290,60 @@ int main()
}
#include <boost/interprocess/detail/config_end.hpp>
/*
//Offset ptr benchmark
#include <vector>
#include <iostream>
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/containers/vector.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/timer.hpp>
#include <cstddef>
template<class InIt,
class Ty> inline
Ty accumulate2(InIt First, InIt Last, Ty Val)
{ // return sum of Val and all in [First, Last)
for (; First != Last; ++First) //First = First + 1)
Val = Val + *First;
return (Val);
}
template <typename Vector>
void time_test(const Vector& vec, std::size_t iterations, const char* label) {
// assert(!vec.empty())
boost::timer t;
typename Vector::const_iterator first = vec.begin();
typename Vector::value_type result(0);
while (iterations != 0) {
result = accumulate2(first, first + vec.size(), result);
--iterations;
}
std::cout << label << t.elapsed() << " " << result << std::endl;
}
int main()
{
using namespace boost::interprocess;
typedef allocator<double, managed_shared_memory::segment_manager> alloc_t;
std::size_t n = 0x1 << 26;
std::size_t file_size = n * sizeof(double) + 1000000;
{
shared_memory_object::remove("MyMappedFile");
managed_shared_memory segment(open_or_create, "MyMappedFile", file_size);
shared_memory_object::remove("MyMappedFile");
alloc_t alloc_inst(segment.get_segment_manager());
vector<double, alloc_t> v0(n, double(42.42), alloc_inst);
time_test(v0, 10, "iterator shared: ");
}
{
std::vector<double> v1(n, double(42.42));
time_test(v1, 10, "iterator non-shared: ");
}
return 0;
}
*/

View File

@@ -157,8 +157,7 @@ int set_test ()
return 1;
}
int i, j;
for(i = 0; i < max/2; ++i){
for(int i = 0; i < max/2; ++i){
IntType move_me(i);
shmset->insert(boost::move(move_me));
stdset->insert(i);
@@ -352,7 +351,7 @@ int set_test ()
}
}
for(i = 0; i < max/2; ++i){
for(int i = 0; i < max/2; ++i){
IntType move_me(i);
shmset->insert(shmset->begin(), boost::move(move_me));
stdset->insert(stdset->begin(), i);
@@ -375,79 +374,81 @@ int set_test ()
return 1;
}
for(i = 0; i < max; ++i){
IntType move_me(i);
shmset->insert(shmset->begin(), boost::move(move_me));
stdset->insert(stdset->begin(), i);
//PrintContainers(shmset, stdset);
IntType move_me2(i);
shmmultiset->insert(shmmultiset->begin(), boost::move(move_me2));
stdmultiset->insert(stdmultiset->begin(), i);
//PrintContainers(shmmultiset, stdmultiset);
if(!CheckEqualContainers(shmset, stdset)){
std::cout << "Error in shmset->insert(shmset->begin(), boost::move(move_me))" << std::endl;
return 1;
}
if(!CheckEqualContainers(shmmultiset, stdmultiset)){
std::cout << "Error in shmmultiset->insert(shmmultiset->begin(), boost::move(move_me2))" << std::endl;
return 1;
}
for(int i = 0; i < max; ++i){
{
IntType move_me(i);
shmset->insert(shmset->begin(), boost::move(move_me));
stdset->insert(stdset->begin(), i);
//PrintContainers(shmset, stdset);
IntType move_me2(i);
shmmultiset->insert(shmmultiset->begin(), boost::move(move_me2));
stdmultiset->insert(stdmultiset->begin(), i);
//PrintContainers(shmmultiset, stdmultiset);
if(!CheckEqualContainers(shmset, stdset)){
std::cout << "Error in shmset->insert(shmset->begin(), boost::move(move_me))" << std::endl;
return 1;
}
if(!CheckEqualContainers(shmmultiset, stdmultiset)){
std::cout << "Error in shmmultiset->insert(shmmultiset->begin(), boost::move(move_me2))" << std::endl;
return 1;
}
IntType move_me3(i);
shmset->insert(shmset->end(), boost::move(move_me3));
stdset->insert(stdset->end(), i);
IntType move_me4(i);
shmmultiset->insert(shmmultiset->end(), boost::move(move_me4));
stdmultiset->insert(stdmultiset->end(), i);
if(!CheckEqualContainers(shmset, stdset)){
std::cout << "Error in shmset->insert(shmset->end(), boost::move(move_me3))" << std::endl;
return 1;
}
if(!CheckEqualContainers(shmmultiset, stdmultiset)){
std::cout << "Error in shmmultiset->insert(shmmultiset->end(), boost::move(move_me4))" << std::endl;
return 1;
IntType move_me3(i);
shmset->insert(shmset->end(), boost::move(move_me3));
stdset->insert(stdset->end(), i);
IntType move_me4(i);
shmmultiset->insert(shmmultiset->end(), boost::move(move_me4));
stdmultiset->insert(stdmultiset->end(), i);
if(!CheckEqualContainers(shmset, stdset)){
std::cout << "Error in shmset->insert(shmset->end(), boost::move(move_me3))" << std::endl;
return 1;
}
if(!CheckEqualContainers(shmmultiset, stdmultiset)){
std::cout << "Error in shmmultiset->insert(shmmultiset->end(), boost::move(move_me4))" << std::endl;
return 1;
}
}
{
IntType move_me(i);
shmset->insert(shmset->upper_bound(move_me), boost::move(move_me));
stdset->insert(stdset->upper_bound(i), i);
//PrintContainers(shmset, stdset);
IntType move_me2(i);
shmmultiset->insert(shmmultiset->upper_bound(move_me2), boost::move(move_me2));
stdmultiset->insert(stdmultiset->upper_bound(i), i);
//PrintContainers(shmmultiset, stdmultiset);
if(!CheckEqualContainers(shmset, stdset)){
std::cout << "Error in shmset->insert(shmset->upper_bound(move_me), boost::move(move_me))" << std::endl;
return 1;
}
if(!CheckEqualContainers(shmmultiset, stdmultiset)){
std::cout << "Error in shmmultiset->insert(shmmultiset->upper_bound(move_me2), boost::move(move_me2))" << std::endl;
return 1;
}
IntType move_me(i);
shmset->insert(shmset->upper_bound(move_me), boost::move(move_me));
stdset->insert(stdset->upper_bound(i), i);
//PrintContainers(shmset, stdset);
IntType move_me2(i);
shmmultiset->insert(shmmultiset->upper_bound(move_me2), boost::move(move_me2));
stdmultiset->insert(stdmultiset->upper_bound(i), i);
//PrintContainers(shmmultiset, stdmultiset);
if(!CheckEqualContainers(shmset, stdset)){
std::cout << "Error in shmset->insert(shmset->upper_bound(move_me), boost::move(move_me))" << std::endl;
return 1;
}
if(!CheckEqualContainers(shmmultiset, stdmultiset)){
std::cout << "Error in shmmultiset->insert(shmmultiset->upper_bound(move_me2), boost::move(move_me2))" << std::endl;
return 1;
}
}
{
IntType move_me(i);
shmset->insert(shmset->lower_bound(move_me), boost::move(move_me2));
stdset->insert(stdset->lower_bound(i), i);
//PrintContainers(shmset, stdset);
IntType move_me2(i);
shmmultiset->insert(shmmultiset->lower_bound(move_me2), boost::move(move_me2));
stdmultiset->insert(stdmultiset->lower_bound(i), i);
//PrintContainers(shmmultiset, stdmultiset);
if(!CheckEqualContainers(shmset, stdset)){
std::cout << "Error in shmset->insert(shmset->lower_bound(move_me), boost::move(move_me2))" << std::endl;
return 1;
}
if(!CheckEqualContainers(shmmultiset, stdmultiset)){
std::cout << "Error in shmmultiset->insert(shmmultiset->lower_bound(move_me2), boost::move(move_me2))" << std::endl;
return 1;
}
IntType move_me(i);
IntType move_me2(i);
shmset->insert(shmset->lower_bound(move_me), boost::move(move_me2));
stdset->insert(stdset->lower_bound(i), i);
//PrintContainers(shmset, stdset);
move_me2 = i;
shmmultiset->insert(shmmultiset->lower_bound(move_me2), boost::move(move_me2));
stdmultiset->insert(stdmultiset->lower_bound(i), i);
//PrintContainers(shmmultiset, stdmultiset);
if(!CheckEqualContainers(shmset, stdset)){
std::cout << "Error in shmset->insert(shmset->lower_bound(move_me), boost::move(move_me2))" << std::endl;
return 1;
}
if(!CheckEqualContainers(shmmultiset, stdmultiset)){
std::cout << "Error in shmmultiset->insert(shmmultiset->lower_bound(move_me2), boost::move(move_me2))" << std::endl;
return 1;
}
}
}
//Compare count with std containers
for(i = 0; i < max; ++i){
for(int i = 0; i < max; ++i){
IntType count_me(i);
if(shmset->count(count_me) != stdset->count(i)){
return -1;
@@ -463,8 +464,8 @@ int set_test ()
shmset->clear();
shmmultiset->clear();
for(j = 0; j < 3; ++j)
for(i = 0; i < 100; ++i){
for(int j = 0; j < 3; ++j)
for(int i = 0; i < 100; ++i){
IntType move_me(i);
shmset->insert(boost::move(move_me));
IntType move_me2(i);
@@ -532,8 +533,7 @@ int set_test_copyable ()
MyStdMultiSet *stdmultiset = new MyStdMultiSet;
int i;
for(i = 0; i < max; ++i){
for(int i = 0; i < max; ++i){
IntType move_me(i);
shmset->insert(boost::move(move_me));
stdset->insert(i);

View File

@@ -31,7 +31,7 @@ struct eraser
}
};
typedef ipcdetail::managed_open_or_create_impl<shared_memory_object> shared_memory;
typedef ipcdetail::managed_open_or_create_impl<shared_memory_object, 0, true, false> shared_memory;
//This wrapper is necessary to have a common constructor
//in generic named_creation_template functions

View File

@@ -12,9 +12,19 @@
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
#include "get_process_id_name.hpp"
//<-
//Shield against external warnings
#include <boost/interprocess/detail/config_external_begin.hpp>
//->
#include <boost/unordered_map.hpp>
#include <boost/unordered_set.hpp>
//<-
#include <boost/interprocess/detail/config_external_end.hpp>
//->
#include <functional> //std::equal_to
#include <boost/functional/hash.hpp> //boost::hash

View File

@@ -105,7 +105,6 @@ int main ()
(heap_buffer.get_segment_manager());
//Alias heap list
typedef std::list<int> MyStdList;
MyStdList *stdlist = new MyStdList;
int i;

View File

@@ -26,12 +26,12 @@ int main ()
{
try{
const char *names[2] = { test::get_process_id_name(), 0 };
for(unsigned int i = 0; i < sizeof(names)/sizeof(names[0]); ++i)
for(unsigned int i_name = 0; i_name < sizeof(names)/sizeof(names[0]); ++i_name)
{
const std::size_t FileSize = 99999*2;
//Create a file mapping
windows_shared_memory mapping
(create_only, names[i], read_write, FileSize);
(create_only, names[i_name], read_write, FileSize);
{

View File

@@ -33,7 +33,7 @@ static const char *name_initialization_routine()
static const std::size_t ShmSize = 1000;
typedef ipcdetail::managed_open_or_create_impl
<windows_shared_memory, 0, false> windows_shared_memory_t;
<windows_shared_memory, 0, false, false> windows_shared_memory_t;
//This wrapper is necessary to have a common constructor
//in generic named_creation_template functions