Modifying data in threads
问题 I have a class with the following structure: class Nginx_sender { private: std::vector<std::string> mMessagesBuffer; boost::mutex mMutex; void SendMessage(const std::string &msg) { mMutex.lock(); mMessagesBuffer.push_back(msg); mMutex.unlock(); std::cout << "Vector size: " << mMessagesBuffer.size() << std::endl; } void NewThreadFunction() { while(true) { mMutex.lock(); if (mMessagesBuffer.size() >= 1) std::cout << ">=1\n"; mMutex.unlock(); boost::this_thread::sleep(boost::posix_time: