|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r79896 - trunk/libs/interprocess/test
From: igaztanaga_at_[hidden]
Date: 2012-08-07 05:08:31
Author: igaztanaga
Date: 2012-08-07 05:08:30 EDT (Tue, 07 Aug 2012)
New Revision: 79896
URL: http://svn.boost.org/trac/boost/changeset/79896
Log:
Modified test for `shrink_by` and `advise` functions in `mapped_region`.
Text files modified:
trunk/libs/interprocess/test/shared_memory_mapping_test.cpp | 50 ++++++++++++++++++++++++++++++++++++++-
1 files changed, 48 insertions(+), 2 deletions(-)
Modified: trunk/libs/interprocess/test/shared_memory_mapping_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/shared_memory_mapping_test.cpp (original)
+++ trunk/libs/interprocess/test/shared_memory_mapping_test.cpp 2012-08-07 05:08:30 EDT (Tue, 07 Aug 2012)
@@ -31,7 +31,7 @@
std::string process_id2(process_id);
process_id2 += "_2";
try{
- const std::size_t FileSize = 99999*2;
+ const std::size_t FileSize = 99999*4;
{
//Remove shared memory
shared_memory_object::remove(process_id.c_str());
@@ -59,7 +59,7 @@
,FileSize - FileSize/2
,0);
- //Fill two regions with a pattern
+ //Fill two regions with a pattern
unsigned char *filler = static_cast<unsigned char*>(region.get_address());
for(std::size_t i = 0
;i < FileSize/2
@@ -129,6 +129,52 @@
return 1;
}
}
+ //Now shrink
+ const std::size_t original_region_size = region.get_size();
+ if(!region.shrink_by(region.get_size()/2, false) || region.get_size() != original_region_size/2){
+ return 1;
+ }
+ const std::size_t shrunk_region_size = region.get_size();
+ if(!region.shrink_by(region.get_size()/2, true) || region.get_size() != shrunk_region_size/2){
+ return 1;
+ }
+
+ //Now advise
+ #if defined(POSIX_MADV_NORMAL) || defined(MADV_NORMAL)
+ std::cout << "Advice normal" << std::endl;
+ if(!region.advise(mapped_region::advice_normal)){
+ return 1;
+ }
+ #endif
+
+ #if defined(POSIX_MADV_SEQUENTIAL) || defined(MADV_SEQUENTIAL)
+ std::cout << "Advice sequential" << std::endl;
+ if(!region.advise(mapped_region::advice_sequential)){
+ return 1;
+ }
+ #endif
+
+ #if defined(POSIX_MADV_RANDOM) || defined(MADV_RANDOM)
+ std::cout << "Advice random" << std::endl;
+ if(!region.advise(mapped_region::advice_random)){
+ return 1;
+ }
+ #endif
+
+ #if defined(POSIX_MADV_WILLNEED) || defined(MADV_WILLNEED)
+ std::cout << "Advice 'will need'" << std::endl;
+ if(!region.advise(mapped_region::advice_willneed)){
+ return 1;
+ }
+ #endif
+
+ #if defined(POSIX_MADV_DONTNEED) || defined(MADV_DONTNEED)
+ std::cout << "Advice 'dont't need'" << std::endl;
+ if(!region.advise(mapped_region::advice_dontneed)){
+ return 1;
+ }
+ #endif
+
}
{
//Check for busy address space
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