mirror of
https://github.com/boostorg/interprocess.git
synced 2026-01-24 05:52:16 +00:00
Full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41369]
This commit is contained in:
@@ -1,46 +0,0 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2006-2007. Distributed under 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/interprocess for documentation.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include <boost/interprocess/detail/config_begin.hpp>
|
||||
//[doc_shared_memory2
|
||||
#include <boost/interprocess/shared_memory_object.hpp>
|
||||
#include <boost/interprocess/mapped_region.hpp>
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
|
||||
int main ()
|
||||
{
|
||||
using namespace boost::interprocess;
|
||||
try{
|
||||
//Open already created shared memory object.
|
||||
shared_memory_object shm (open_only, "shared_memory", read_only);
|
||||
|
||||
//Map the whole shared memory in this process
|
||||
mapped_region region(shm, read_only);
|
||||
|
||||
//Check that memory was initialized to 1
|
||||
const char *mem = static_cast<char*>(region.get_address());
|
||||
for(std::size_t i = 0; i < region.get_size(); ++i){
|
||||
if(*mem++ != 1){
|
||||
std::cout << "Error checking memory!" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
std::cout << "Test successful!" << std::endl;
|
||||
}
|
||||
catch(interprocess_exception &ex){
|
||||
std::cout << "Unexpected exception: " << ex.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
//]
|
||||
|
||||
#include <boost/interprocess/detail/config_end.hpp>
|
||||
Reference in New Issue
Block a user