]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/interprocess/example/doc_anonymous_shared_memory.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / interprocess / example / doc_anonymous_shared_memory.cpp
CommitLineData
7c673cae
FG
1//////////////////////////////////////////////////////////////////////////////
2//
3// (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost
4// Software License, Version 1.0. (See accompanying file
5// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7// See http://www.boost.org/libs/interprocess for documentation.
8//
9//////////////////////////////////////////////////////////////////////////////
1e59de90 10
7c673cae
FG
11//[doc_anonymous_shared_memory
12#include <boost/interprocess/anonymous_shared_memory.hpp>
13#include <boost/interprocess/mapped_region.hpp>
14#include <iostream>
15#include <cstring>
16
17int main ()
18{
19 using namespace boost::interprocess;
1e59de90 20 BOOST_TRY{
7c673cae
FG
21 //Create an anonymous shared memory segment with size 1000
22 mapped_region region(anonymous_shared_memory(1000));
23
24 //Write all the memory to 1
25 std::memset(region.get_address(), 1, region.get_size());
26
27 //The segment is unmapped when "region" goes out of scope
28 }
1e59de90 29 BOOST_CATCH(interprocess_exception &ex){
7c673cae
FG
30 std::cout << ex.what() << std::endl;
31 return 1;
1e59de90 32 } BOOST_CATCH_END
7c673cae
FG
33 return 0;
34}
35//]
1e59de90 36