| 270 | } |
| 271 | |
| 272 | void EventsRouter::Subscribe(const std::set<EventType>& types, const EventsInbox::Ptr& inbox) |
| 273 | { |
| 274 | const auto& filter (inbox->GetFilter()); |
| 275 | std::unique_lock<std::mutex> lock (m_Mutex); |
| 276 | |
| 277 | for (auto type : types) { |
| 278 | auto perType (m_Subscribers.find(type)); |
| 279 | |
| 280 | if (perType == m_Subscribers.end()) { |
| 281 | perType = m_Subscribers.emplace(type, decltype(perType->second)()).first; |
| 282 | } |
| 283 | |
| 284 | auto perFilter (perType->second.find(filter)); |
| 285 | |
| 286 | if (perFilter == perType->second.end()) { |
| 287 | perFilter = perType->second.emplace(filter, decltype(perFilter->second)()).first; |
| 288 | } |
| 289 | |
| 290 | perFilter->second.emplace(inbox); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | void EventsRouter::Unsubscribe(const std::set<EventType>& types, const EventsInbox::Ptr& inbox) |
| 295 | { |
no test coverage detected