mirror of
https://github.com/boostorg/interprocess.git
synced 2026-01-30 20:02:13 +00:00
Merged Interprocess + Intrusive revision 42982 from trunk to release branch
[SVN r42994]
This commit is contained in:
@@ -14,52 +14,74 @@
|
||||
#include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
|
||||
#include <boost/interprocess/indexes/null_index.hpp>
|
||||
#include <boost/interprocess/sync/mutex_family.hpp>
|
||||
#include <boost/interprocess/detail/type_traits.hpp>
|
||||
#include "memory_algorithm_test_template.hpp"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "get_process_id_name.hpp"
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
const int memsize = 16384;
|
||||
const char *const shMemName = test::get_process_id_name();
|
||||
|
||||
int test_simple_seq_fit()
|
||||
{
|
||||
//A shared memory with simple sequential fit algorithm
|
||||
typedef basic_managed_shared_memory
|
||||
<char
|
||||
,simple_seq_fit<mutex_family>
|
||||
,null_index
|
||||
> my_managed_shared_memory;
|
||||
|
||||
//Create shared memory
|
||||
shared_memory_object::remove(shMemName);
|
||||
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())){
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<std::size_t Alignment>
|
||||
int test_rbtree_best_fit()
|
||||
{
|
||||
//A shared memory with red-black tree best fit algorithm
|
||||
typedef basic_managed_shared_memory
|
||||
<char
|
||||
,rbtree_best_fit<mutex_family, offset_ptr<void>, Alignment>
|
||||
,null_index
|
||||
> my_managed_shared_memory;
|
||||
|
||||
//Create shared memory
|
||||
shared_memory_object::remove(shMemName);
|
||||
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())){
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main ()
|
||||
{
|
||||
using namespace boost::interprocess;
|
||||
const int memsize = 16384;
|
||||
const char *const shMemName = test::get_process_id_name();
|
||||
|
||||
{
|
||||
//A shared memory with simple sequential fit algorithm
|
||||
typedef basic_managed_shared_memory
|
||||
<char
|
||||
,simple_seq_fit<mutex_family>
|
||||
,null_index
|
||||
> my_managed_shared_memory;
|
||||
|
||||
//Create shared memory
|
||||
shared_memory_object::remove(shMemName);
|
||||
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())){
|
||||
return 1;
|
||||
}
|
||||
const std::size_t void_ptr_align = detail::alignment_of<void*>::value;
|
||||
if(test_simple_seq_fit()){
|
||||
return 1;
|
||||
}
|
||||
if(test_rbtree_best_fit<void_ptr_align>()){
|
||||
return 1;
|
||||
}
|
||||
if(test_rbtree_best_fit<2*void_ptr_align>()){
|
||||
return 1;
|
||||
}
|
||||
if(test_rbtree_best_fit<4*void_ptr_align>()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
{
|
||||
//A shared memory with red-black tree best fit algorithm
|
||||
typedef basic_managed_shared_memory
|
||||
<char
|
||||
,rbtree_best_fit<mutex_family>
|
||||
,null_index
|
||||
> my_managed_shared_memory;
|
||||
|
||||
//Create shared memory
|
||||
shared_memory_object::remove(shMemName);
|
||||
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())){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
shared_memory_object::remove(shMemName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user