mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 15:14:07 +02:00
Fix: Only take one work item from the event queue per iteration.
This commit is contained in:
parent
876519034c
commit
0f9acdffbb
@ -78,7 +78,7 @@ void EventQueue::Join(void)
|
||||
void EventQueue::QueueThreadProc(void)
|
||||
{
|
||||
for (;;) {
|
||||
vector<Callback> events;
|
||||
Callback event;
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_Mutex);
|
||||
@ -89,10 +89,10 @@ void EventQueue::QueueThreadProc(void)
|
||||
if (m_Events.empty() && m_Stopped)
|
||||
break;
|
||||
|
||||
events.swap(m_Events);
|
||||
event = m_Events.top();
|
||||
m_Events.pop();
|
||||
}
|
||||
|
||||
BOOST_FOREACH(const Callback& ev, events) {
|
||||
#ifdef _DEBUG
|
||||
double st = Utility::GetTime();
|
||||
|
||||
@ -104,7 +104,7 @@ void EventQueue::QueueThreadProc(void)
|
||||
#endif /* _DEBUG */
|
||||
|
||||
try {
|
||||
ev();
|
||||
event();
|
||||
} catch (const std::exception& ex) {
|
||||
stringstream msgbuf;
|
||||
msgbuf << "Exception thrown in event handler: " << std::endl
|
||||
@ -146,7 +146,6 @@ void EventQueue::QueueThreadProc(void)
|
||||
}
|
||||
#endif /* _DEBUG */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,7 +157,7 @@ void EventQueue::QueueThreadProc(void)
|
||||
void EventQueue::Post(const EventQueue::Callback& callback)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_Mutex);
|
||||
m_Events.push_back(callback);
|
||||
m_Events.push(callback);
|
||||
m_CV.notify_one();
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ private:
|
||||
condition_variable m_CV;
|
||||
|
||||
bool m_Stopped;
|
||||
vector<Callback> m_Events;
|
||||
stack<Callback> m_Events;
|
||||
|
||||
void QueueThreadProc(void);
|
||||
void ReportThreadProc(void);
|
||||
|
@ -91,6 +91,7 @@
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
#include <deque>
|
||||
#include <stack>
|
||||
#include <iterator>
|
||||
|
||||
using std::vector;
|
||||
@ -101,6 +102,7 @@ using std::multimap;
|
||||
using std::multiset;
|
||||
using std::pair;
|
||||
using std::deque;
|
||||
using std::stack;
|
||||
using std::make_pair;
|
||||
|
||||
using std::stringstream;
|
||||
|
Loading…
x
Reference in New Issue
Block a user