如果需要加锁用以下方式加锁有没有问题。class A{public:A();~A();public:std::hash_map<__int64,LPVOID> act_var;public:LPVOID read(__int64);private:kelib::mutex::MutexLock mutex_;};A::A(){}A::~A(){}LPVOID A::read(__int64 index){kelib::mutex::MutexLockGuard lock(mutex_); //加锁std::hash_map<__int64,LPVOID>::iterator iter=act_var.find(index);if(iter!=act_var.end()){return (*iter).second;}return NULL;}
添加回答
举报
0/150
提交
取消