I have a multithreaded server application that needs mutex locks over some shared memory.
The shared memory are basically sTL maps etc.
Much of the time I\'m
You don't want boost-interprocess if you're just using a single process. As the library name implies, it's used for Inter-Process Communication (IPC). You most likely want to use the boost-thread mutex and locking concepts.
#include
#include
int
main()
{
typedef boost::shared_mutex Mutex;
typedef boost::shared_lock ReadLock;
typedef boost::unique_lock WriteLock;
Mutex mutex;
{
// acquire read lock
ReadLock read( mutex );
// do something to read resource
}
{
// acquire write lock
WriteLock write( mutex, boost::adopt_lock_t() );
// do something to write resource
}
}
there's a post on the boost mailing list explaining this as well.