"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/remote/eventqueue.cpp" between
icinga2-2.11.5.tar.gz and icinga2-2.12.0.tar.gz

About: Icinga 2 is an enterprise grade monitoring system which keeps watch over networks and any conceivable network resource.

eventqueue.cpp  (icinga2-2.11.5):eventqueue.cpp  (icinga2-2.12.0)
skipping to change at line 93 skipping to change at line 93
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(m_Mutex);
m_Types = types; m_Types = types;
} }
void EventQueue::SetFilter(std::unique_ptr<Expression> filter) void EventQueue::SetFilter(std::unique_ptr<Expression> filter)
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(m_Mutex);
m_Filter.swap(filter); m_Filter.swap(filter);
} }
Dictionary::Ptr EventQueue::WaitForEvent(void *client, double timeout)
{
boost::mutex::scoped_lock lock(m_Mutex);
for (;;) {
auto it = m_Events.find(client);
ASSERT(it != m_Events.end());
if (!it->second.empty()) {
Dictionary::Ptr result = *it->second.begin();
it->second.pop_front();
return result;
}
if (!m_CV.timed_wait(lock, boost::posix_time::milliseconds(long(t
imeout * 1000))))
return nullptr;
}
}
std::vector<EventQueue::Ptr> EventQueue::GetQueuesForType(const String& type) std::vector<EventQueue::Ptr> EventQueue::GetQueuesForType(const String& type)
{ {
EventQueueRegistry::ItemMap queues = EventQueueRegistry::GetInstance()->G etItems(); EventQueueRegistry::ItemMap queues = EventQueueRegistry::GetInstance()->G etItems();
std::vector<EventQueue::Ptr> availQueues; std::vector<EventQueue::Ptr> availQueues;
typedef std::pair<String, EventQueue::Ptr> kv_pair; typedef std::pair<String, EventQueue::Ptr> kv_pair;
for (const kv_pair& kv : queues) { for (const kv_pair& kv : queues) {
if (kv.second->CanProcessEvent(type)) if (kv.second->CanProcessEvent(type))
availQueues.push_back(kv.second); availQueues.push_back(kv.second);
skipping to change at line 129 skipping to change at line 148
{ {
EventQueueRegistry::GetInstance()->Unregister(name); EventQueueRegistry::GetInstance()->Unregister(name);
} }
EventQueueRegistry *EventQueueRegistry::GetInstance() EventQueueRegistry *EventQueueRegistry::GetInstance()
{ {
return Singleton<EventQueueRegistry>::GetInstance(); return Singleton<EventQueueRegistry>::GetInstance();
} }
std::mutex EventsInbox::m_FiltersMutex; std::mutex EventsInbox::m_FiltersMutex;
std::map<String, EventsInbox::Filter> EventsInbox::m_Filters ({{"", EventsInbox: :Filter{1, nullptr}}}); std::map<String, EventsInbox::Filter> EventsInbox::m_Filters ({{"", EventsInbox: :Filter{1, Expression::Ptr()}}});
EventsRouter EventsRouter::m_Instance; EventsRouter EventsRouter::m_Instance;
EventsInbox::EventsInbox(String filter, const String& filterSource) EventsInbox::EventsInbox(String filter, const String& filterSource)
: m_Timer(IoEngine::Get().GetIoContext()) : m_Timer(IoEngine::Get().GetIoContext())
{ {
std::unique_lock<std::mutex> lock (m_FiltersMutex); std::unique_lock<std::mutex> lock (m_FiltersMutex);
m_Filter = m_Filters.find(filter); m_Filter = m_Filters.find(filter);
if (m_Filter == m_Filters.end()) { if (m_Filter == m_Filters.end()) {
lock.unlock(); lock.unlock();
auto expr (ConfigCompiler::CompileText(filterSource, filter)); auto expr (ConfigCompiler::CompileText(filterSource, filter));
lock.lock(); lock.lock();
m_Filter = m_Filters.find(filter); m_Filter = m_Filters.find(filter);
if (m_Filter == m_Filters.end()) { if (m_Filter == m_Filters.end()) {
m_Filter = m_Filters.emplace(std::move(filter), Filter{1, std::shared_ptr<Expression>(expr.release())}).first; m_Filter = m_Filters.emplace(std::move(filter), Filter{1, Expression::Ptr(expr.release())}).first;
} else { } else {
++m_Filter->second.Refs; ++m_Filter->second.Refs;
} }
} else { } else {
++m_Filter->second.Refs; ++m_Filter->second.Refs;
} }
} }
EventsInbox::~EventsInbox() EventsInbox::~EventsInbox()
{ {
std::unique_lock<std::mutex> lock (m_FiltersMutex); std::unique_lock<std::mutex> lock (m_FiltersMutex);
if (!--m_Filter->second.Refs) { if (!--m_Filter->second.Refs) {
m_Filters.erase(m_Filter); m_Filters.erase(m_Filter);
} }
} }
const std::shared_ptr<Expression>& EventsInbox::GetFilter() const Expression::Ptr& EventsInbox::GetFilter()
{ {
return m_Filter->second.Expr; return m_Filter->second.Expr;
} }
void EventsInbox::Push(Dictionary::Ptr event) void EventsInbox::Push(Dictionary::Ptr event)
{ {
std::unique_lock<std::mutex> lock (m_Mutex); std::unique_lock<std::mutex> lock (m_Mutex);
m_Queue.emplace(std::move(event)); m_Queue.emplace(std::move(event));
m_Timer.expires_at(boost::posix_time::neg_infin); m_Timer.expires_at(boost::posix_time::neg_infin);
skipping to change at line 233 skipping to change at line 252
EventsSubscriber::~EventsSubscriber() EventsSubscriber::~EventsSubscriber()
{ {
EventsRouter::GetInstance().Unsubscribe(m_Types, m_Inbox); EventsRouter::GetInstance().Unsubscribe(m_Types, m_Inbox);
} }
const EventsInbox::Ptr& EventsSubscriber::GetInbox() const EventsInbox::Ptr& EventsSubscriber::GetInbox()
{ {
return m_Inbox; return m_Inbox;
} }
EventsFilter::EventsFilter(std::map<std::shared_ptr<Expression>, std::set<Events Inbox::Ptr>> inboxes) EventsFilter::EventsFilter(std::map<Expression::Ptr, std::set<EventsInbox::Ptr>> inboxes)
: m_Inboxes(std::move(inboxes)) : m_Inboxes(std::move(inboxes))
{ {
} }
EventsFilter::operator bool() EventsFilter::operator bool()
{ {
return !m_Inboxes.empty(); return !m_Inboxes.empty();
} }
void EventsFilter::Push(Dictionary::Ptr event) void EventsFilter::Push(Dictionary::Ptr event)
 End of changes. 5 change blocks. 
4 lines changed or deleted 24 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)