mirror of https://github.com/Icinga/icinga2.git
parent
12c8814bd8
commit
6a8db4035d
|
@ -151,6 +151,8 @@ Array::Ptr ScriptUtils::Range(const std::vector<Value>& arguments)
|
|||
end = arguments[1];
|
||||
increment = arguments[2];
|
||||
break;
|
||||
default:
|
||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid number of arguments for range()"));
|
||||
}
|
||||
|
||||
Array::Ptr result = make_shared<Array>();
|
||||
|
|
|
@ -33,10 +33,10 @@ using namespace icinga;
|
|||
|
||||
int ThreadPool::m_NextID = 1;
|
||||
|
||||
ThreadPool::ThreadPool(int max_threads)
|
||||
ThreadPool::ThreadPool(size_t max_threads)
|
||||
: m_ID(m_NextID++), m_MaxThreads(max_threads), m_Stopped(false)
|
||||
{
|
||||
if (m_MaxThreads != -1 && m_MaxThreads < sizeof(m_Queues) / sizeof(m_Queues[0]))
|
||||
if (m_MaxThreads != UINT_MAX && m_MaxThreads < sizeof(m_Queues) / sizeof(m_Queues[0]))
|
||||
m_MaxThreads = sizeof(m_Queues) / sizeof(m_Queues[0]);
|
||||
|
||||
Start();
|
||||
|
@ -242,7 +242,7 @@ void ThreadPool::ManagerThreadProc(void)
|
|||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < sizeof(m_Queues) / sizeof(m_Queues[0]); i++) {
|
||||
for (size_t i = 0; i < sizeof(m_Queues) / sizeof(m_Queues[0]); i++) {
|
||||
size_t pending, alive = 0;
|
||||
double avg_latency;
|
||||
double utilization = 0;
|
||||
|
@ -287,7 +287,7 @@ void ThreadPool::ManagerThreadProc(void)
|
|||
if (tthreads > 0 && pending > 0)
|
||||
tthreads = 8;
|
||||
|
||||
if (m_MaxThreads != -1 && (alive + tthreads) * (sizeof(m_Queues) / sizeof(m_Queues[0])) > m_MaxThreads)
|
||||
if (m_MaxThreads != UINT_MAX && (alive + tthreads) * (sizeof(m_Queues) / sizeof(m_Queues[0])) > m_MaxThreads)
|
||||
tthreads = m_MaxThreads / (sizeof(m_Queues) / sizeof(m_Queues[0])) - alive;
|
||||
|
||||
if (tthreads != 0) {
|
||||
|
@ -383,7 +383,7 @@ void ThreadPool::WorkerThread::UpdateUtilization(ThreadState state)
|
|||
utilization = 1;
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
VERIFY(0);
|
||||
}
|
||||
|
||||
double now = Utility::GetTime();
|
||||
|
|
|
@ -40,7 +40,7 @@ class I2_BASE_API ThreadPool
|
|||
public:
|
||||
typedef boost::function<void ()> WorkFunction;
|
||||
|
||||
ThreadPool(int max_threads = -1);
|
||||
ThreadPool(size_t max_threads = UINT_MAX);
|
||||
~ThreadPool(void);
|
||||
|
||||
void Start(void);
|
||||
|
@ -110,7 +110,7 @@ private:
|
|||
int m_ID;
|
||||
static int m_NextID;
|
||||
|
||||
unsigned int m_MaxThreads;
|
||||
size_t m_MaxThreads;
|
||||
|
||||
boost::thread_group m_ThreadGroup;
|
||||
|
||||
|
|
|
@ -402,7 +402,6 @@ Dictionary::Ptr LegacyTimePeriod::FindNextSegment(const String& daydef, const St
|
|||
iter = begin;
|
||||
|
||||
tsend = mktime(&end);
|
||||
tsiter = mktime(&iter);
|
||||
|
||||
do {
|
||||
if (IsInTimeRange(&begin, &end, stride, &iter)) {
|
||||
|
|
Loading…
Reference in New Issue