i am using boost mutex in MessageQueue class as a private member in the following method
void MessageQueue::Dequeuee()
{
Request rq(messageWareHouse.front().reqID,messageWareHouse.front().seq,
messageWareHouse.front().sMessage);
while(true)
{
boost::unique_lock<boost::mutex> lock(qMutex);
qCond.wait(lock);
**reqCollection**.find(messageWareHouse.front().reqID)->second.addSegments(messageWareHouse.front().seq,
messageWareHouse.front().sMessage );
}
....
reqCollection is a map
map<size_t, Request> reqCollection;
Inside Request when i try to initialize the mutex i am getting the below error
class Request
{
private:
size_t RequestID;
public:
boost::mutex qMutex;
Request(size_t requestID,size_t seq, std::string sMessage);
void addSegments(size_t seq, std::string sMessage);
};
as far as i searched this error in google here the solution for the problem is stated as
Place (smart) pointers for the mutex or the class containing the mutex
but does this mean i can only use one mutex variable in my whole project by passing pointers? Why boost is protecting the mutex
the error is
Error 7 error C2248: 'boost::mutex::mutex' : cannot access private member declared in class 'boost::mutex'