void Client::write(MessagePtr msg) { if (!mRunning) return; // encodes message before sending msg->encode(); // append the message boost::lock_guard<boost::mutex> lock(mWMutex); mWriteQ.push_back(msg); boost::lock_guard<boost::mutex> slock(mSMutex); mSent.push_back(std::string(msg->body())); // notify of new message mWCond.notify_one(); }