优化代码

This commit is contained in:
xiongziliang 2020-04-06 21:44:32 +08:00
parent 45c5f1ec4c
commit 1896b1d768

View File

@ -210,17 +210,18 @@ public:
* @param frame * @param frame
*/ */
void inputFrame(const Frame::Ptr &frame) override{ void inputFrame(const Frame::Ptr &frame) override{
//_delegates_read能确保是单线程操作的
for(auto &pr : _delegates_read){
pr.second->inputFrame(frame);
}
if(_need_update){ if(_need_update){
//发现代理列表发生变化了,这里同步一次 //发现代理列表发生变化了,这里同步一次
lock_guard<mutex> lck(_mtx); lock_guard<mutex> lck(_mtx);
_delegates_read = _delegates_write; _delegates_read = _delegates_write;
_need_update = false; _need_update = false;
} }
//_delegates_read能确保是单线程操作的
for(auto &pr : _delegates_read){
pr.second->inputFrame(frame);
}
} }
private: private:
mutex _mtx; mutex _mtx;