Last active
September 24, 2018 15:05
-
-
Save nglee/a03ed8c2de387608f6d9d98ce53beb51 to your computer and use it in GitHub Desktop.
Persistence of interprocess_mutex
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_xsi_shared_memory.hpp> | |
#include <boost/interprocess/xsi_key.hpp> | |
#include <iostream> | |
using namespace boost::interprocess; | |
int main() | |
{ | |
managed_xsi_shared_memory *shm = nullptr; | |
try { | |
shm = new managed_xsi_shared_memory{ open_or_create, xsi_key("bitest2.cpp", 239), 1024 }; | |
} catch (interprocess_exception& e) { | |
std::cout << e.what() << std::endl; | |
std::cout << "managed_xsi_shared_memory open_or_create fail" << std::endl; | |
} | |
try { | |
interprocess_mutex *mtx = shm->construct<interprocess_mutex>("gMutex")(); | |
if (mtx) | |
std::cout << "interprocess_mutex create success" << std::endl; | |
else | |
std::cout << "interprocess_mutex create fail" << std::endl; | |
} catch (interprocess_exception& e) { | |
std::cout << e.what() << std::endl; | |
std::cout << "interprocess_mutex create fail" << std::endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment