Last active
July 17, 2018 01:32
-
-
Save nglee/f89b6448a05edcb9ed382a94e8aa13d5 to your computer and use it in GitHub Desktop.
Persistence of managed_windows_shared_memory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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