size_t Listener::HandleBroadcastEvent(EventSP &event_sp) { size_t num_handled = 0; std::lock_guard<std::recursive_mutex> guard(m_broadcasters_mutex); Broadcaster *broadcaster = event_sp->GetBroadcaster(); if (!broadcaster) return 0; broadcaster_collection::iterator pos; broadcaster_collection::iterator end = m_broadcasters.end(); Broadcaster::BroadcasterImplSP broadcaster_impl_sp( broadcaster->GetBroadcasterImpl()); for (pos = m_broadcasters.find(broadcaster_impl_sp); pos != end && pos->first.lock() == broadcaster_impl_sp; ++pos) { BroadcasterInfo info = pos->second; if (event_sp->GetType() & info.event_mask) { if (info.callback != nullptr) { info.callback(event_sp, info.callback_user_data); ++num_handled; } } } return num_handled; }
size_t Listener::HandleBroadcastEvent (EventSP &event_sp) { size_t num_handled = 0; Mutex::Locker locker(m_broadcasters_mutex); Broadcaster *broadcaster = event_sp->GetBroadcaster(); broadcaster_collection::iterator pos; broadcaster_collection::iterator end = m_broadcasters.end(); for (pos = m_broadcasters.find (broadcaster); pos != end && pos->first == broadcaster; ++pos) { BroadcasterInfo info = pos->second; if (event_sp->GetType () & info.event_mask) { if (info.callback != NULL) { info.callback (event_sp, info.callback_user_data); ++num_handled; } } } return num_handled; }