| 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 |
|
|---|
| 6 | typedef boost::shared_ptr<boost::interprocess::named_mutex> safe_ipc_mx;
|
|---|
| 7 |
|
|---|
| 8 | static safe_ipc_mx __mx;
|
|---|
| 9 | int 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 | }
|
|---|