dynamically allocated mutex: unlock before you destroy it!
This object is not copyable or assignable, but it does let you dynamically create a mutex.
You cannot store these objects in a container, because they are uncopyable. However, you can store shared pointers to them easily, e.g.:
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
std::vector<boost::shared_ptr<kjb::Pthread_mutex> > foo_lock;
while (foo_lock.size() < PROPER_SIZE)
{
foo_lock.push_back(boost::make_shared<kjb::Pthread_mutex>());
}
- Warning
- You are obliged to make sure the mutex is unlocked before you destroy it!
- See Also
- Pthread_locked_mutex