1 | #include <stdlib.h>
|
---|
2 | #include <boost/interprocess/sync/named_mutex.hpp>
|
---|
3 |
|
---|
4 | int main(void) {
|
---|
5 |
|
---|
6 | using namespace boost::interprocess;
|
---|
7 |
|
---|
8 | named_mutex mutex(open_or_create, "mutX"); // This mutex is non-recursive
|
---|
9 | // the mutex should be unlocked initially
|
---|
10 |
|
---|
11 | mutex.unlock(); // This should have no effect, as it already is unlocked
|
---|
12 | mutex.unlock(); // This should have no effect, as it already is unlocked
|
---|
13 |
|
---|
14 | mutex.lock(); // Now the mutex should be locked
|
---|
15 | mutex.lock(); // This should never return, as the mutex is already locked!
|
---|
16 |
|
---|
17 | return EXIT_FAILURE; // In case we arrived here, something went wrong
|
---|
18 | }
|
---|
19 |
|
---|