mirror of
https://github.com/boostorg/interprocess.git
synced 2026-01-19 04:12:13 +00:00
Add minimal "BOOST_INTERPROCESS_FORCE_NATIVE_EMULATION" test
This commit is contained in:
34
test/managed_force_native_emulation_test.cpp
Normal file
34
test/managed_force_native_emulation_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2024-2024. 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.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define BOOST_INTERPROCESS_FORCE_NATIVE_EMULATION 1 // This is important, doesn't crash otherwise.
|
||||
|
||||
#include <boost/interprocess/managed_shared_memory.hpp>
|
||||
#include "get_process_id_name.hpp"
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
int main()
|
||||
{
|
||||
const int MemSize = 65536;
|
||||
const char* const MemName = test::get_process_id_name();
|
||||
|
||||
{
|
||||
managed_shared_memory mshm(open_or_create, MemName, MemSize);
|
||||
shared_memory_object::remove(MemName);
|
||||
|
||||
for (std::size_t i = 0; i != 1000; ++i) {
|
||||
mshm.deallocate(mshm.allocate(i));
|
||||
}
|
||||
} //Force early destruction of shared memory
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user