Ticket #11194: main.3.cpp

File main.3.cpp, 714 bytes (added by trivelli.lorenzo@…, 8 years ago)
Line 
1#include <boost/shared_ptr.hpp>
2#include <boost/interprocess/sync/named_mutex.hpp>
3#include <boost/interprocess/sync/scoped_lock.hpp>
4#include <iostream>
5
6typedef boost::shared_ptr<boost::interprocess::named_mutex> safe_ipc_mx;
7
8static safe_ipc_mx __mx;
9int main(void) {
10 system("pause");
11 try {
12 __mx = safe_ipc_mx(new boost::interprocess::named_mutex(boost::interprocess::open_or_create_t(),"JAEGER"));
13 std::cout << std::endl << "Mutex created !" << std::endl;
14 } catch(boost::interprocess::interprocess_exception const& e) {
15 std::cout << std::endl << "Mutex creation error " << e.what() << " /" << e.get_error_code() << " /" << e.get_native_error();
16 }
17 system("pause");
18 return 0;
19
20}