Skip to content

Instantly share code, notes, and snippets.

@nglee
Last active July 17, 2018 01:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nglee/f89b6448a05edcb9ed382a94e8aa13d5 to your computer and use it in GitHub Desktop.
Save nglee/f89b6448a05edcb9ed382a94e8aa13d5 to your computer and use it in GitHub Desktop.
Persistence of managed_windows_shared_memory
#include <boost/interprocess/managed_windows_shared_memory.hpp>
#include <iostream>
using namespace boost::interprocess;
int main()
{
managed_windows_shared_memory *shm = nullptr;
try {
shm = new managed_windows_shared_memory{ create_only, "shm", 1024 };
std::cout << "shared memory created" << std::endl;
} catch (interprocess_exception& e) {
std::cout << e.what() << std::endl;
shm = new managed_windows_shared_memory{ open_only, "shm" };
std::cout << "shared memory creation failed, opened instead" << std::endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment