MCPcopy Create free account
hub / github.com/Icinga/icinga2 / Subscribe

Method Subscribe

lib/remote/eventqueue.cpp:272–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270}
271
272void 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
294void EventsRouter::Unsubscribe(const std::set<EventType>& types, const EventsInbox::Ptr& inbox)
295{

Callers 1

EventsSubscriberMethod · 0.80

Calls 3

findMethod · 0.80
emplaceMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected