mirror of https://github.com/Icinga/icinga2.git
parent
85fec966b8
commit
f9c53ad295
|
@ -21,6 +21,7 @@
|
|||
#include "base/utility.h"
|
||||
#include "base/debug.h"
|
||||
#include "base/logger_fwd.h"
|
||||
#include "base/convert.h"
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
using namespace icinga;
|
||||
|
@ -29,7 +30,8 @@ int WorkQueue::m_NextID = 1;
|
|||
|
||||
WorkQueue::WorkQueue(size_t maxItems)
|
||||
: m_ID(m_NextID++), m_MaxItems(maxItems), m_Joined(false),
|
||||
m_Stopped(false), m_ExceptionCallback(WorkQueue::DefaultExceptionCallback)
|
||||
m_Stopped(false), m_ExceptionCallback(WorkQueue::DefaultExceptionCallback),
|
||||
m_LastStatus(0)
|
||||
{
|
||||
m_Thread = boost::thread(boost::bind(&WorkQueue::WorkerThreadProc, this));
|
||||
}
|
||||
|
@ -109,6 +111,13 @@ void WorkQueue::ProcessItems(boost::mutex::scoped_lock& lock, bool interleaved)
|
|||
m_Items.pop_front();
|
||||
m_CV.notify_all();
|
||||
|
||||
double now = Utility::GetTime();
|
||||
|
||||
if (m_LastStatus + 10 < now) {
|
||||
Log(LogInformation, "base", "WQ items: " + Convert::ToString(m_Items.size()));
|
||||
m_LastStatus = now;
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
wi.Callback();
|
||||
} catch (const std::exception& ex) {
|
||||
|
|
|
@ -72,6 +72,7 @@ private:
|
|||
bool m_Stopped;
|
||||
std::deque<WorkItem> m_Items;
|
||||
ExceptionCallback m_ExceptionCallback;
|
||||
double m_LastStatus;
|
||||
|
||||
void ProcessItems(boost::mutex::scoped_lock& lock, bool interleaved);
|
||||
void WorkerThreadProc(void);
|
||||
|
|
Loading…
Reference in New Issue