Ion GaztaƱaga wrote:
I don't have a MacOs to test the code and I didn't know people was trying to use it with MacOS. But glad to know you are trying. Anyway, you are erasing the mutex and the before the scoped_lock destructor is called. That means that the destructor of the scoped_lock will try to access to a mutex that's already destroyed. This does not seem correct. The "remove" function should be after the mutex is used. Something like:
try { { bi::named_mutex directoryMutex( bi::create_only, "MyVeryUniquelyNamedMutex" ); cout << "Creating scoped lock" << endl; bi::scoped_lockbi::named_mutex lock( directoryMutex ); cout << "All reqs met. Destroying mutex" << endl; } bi::named_mutex::remove( "MyVeryUniquelyNamedMutex" ); } catch( std::exception &e ) { cout << "Problem encountered: " << e.what() << endl; }
Right--whoops. Unfortunately, the code never appears to reach that point. Getting rid of the remove entirely results in the same output: Creating mutex Problem encountered: I also can't debug it using gdb for some reason, which makes this a bit difficult. What platforms would you expect the current code to work on? Thanks.