mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-05 10:58:11 +08:00
listStreamProxy与listStreamPusherProxy支持key筛选参数
This commit is contained in:
@@ -295,12 +295,20 @@ public:
|
||||
return it->second;
|
||||
}
|
||||
|
||||
void for_each(const std::function<void(const std::string&, const Pointer&)>& cb) {
|
||||
void for_each(const std::function<void(const std::string &, const Pointer &)> &cb, const std::string &key = {}) {
|
||||
std::lock_guard<std::recursive_mutex> lck(_mtx);
|
||||
auto it = _map.begin();
|
||||
while (it != _map.end()) {
|
||||
cb(it->first, it->second);
|
||||
it++;
|
||||
if (key.empty()) {
|
||||
auto it = _map.begin();
|
||||
while (it != _map.end()) {
|
||||
cb(it->first, it->second);
|
||||
++it;
|
||||
}
|
||||
} else {
|
||||
auto it = _map.find(key);
|
||||
if (it == _map.end()) {
|
||||
throw std::invalid_argument("key not found: " + key);
|
||||
}
|
||||
cb(key, it->second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user