Application::DeclareApplicationType("icinga/IcingaApplication");
Application::DeclareRunAsUser(ICINGA_USER);
Application::DeclareRunAsGroup(ICINGA_GROUP);
+ Application::DeclareConcurrency(boost::thread::hardware_concurrency());
LogSeverity logLevel = Logger::GetConsoleLogSeverity();
Logger::SetConsoleLogSeverity(LogWarning);
{
ScriptVariable::Set("RunAsUser", user, false);
}
+
/**
* Retrieves the name of the group.
*
return ScriptVariable::Get("RunAsGroup");
}
+/**
+ * Sets the concurrency level.
+ *
+ * @param path The new concurrency level.
+ */
+void Application::DeclareConcurrency(int ncpus)
+{
+ ScriptVariable::Set("Concurrency", ncpus, false);
+}
+
+/**
+ * Retrieves the concurrency level.
+ *
+ * @returns The concurrency level.
+ */
+int Application::GetConcurrency(void)
+{
+ Value defaultConcurrency = boost::thread::hardware_concurrency();
+ return ScriptVariable::Get("Concurrency", &defaultConcurrency);
+}
+
/**
* Sets the name of the group.
*
static String GetRunAsGroup(void);
static void DeclareRunAsGroup(const String& group);
+ static int GetConcurrency(void);
+ static void DeclareConcurrency(int ncpus);
+
static void MakeVariablesConstant(void);
static ThreadPool& GetTP(void);
#include "base/debug.hpp"
#include "base/utility.hpp"
#include "base/exception.hpp"
+#include "base/application.hpp"
#include <boost/bind.hpp>
#include <iostream>
int tthreads = wthreads - alive;
/* Make sure there is at least one thread per CPU */
- int ncput = std::max(boost::thread::hardware_concurrency() / QUEUECOUNT, 4U);
+ int ncput = std::max(static_cast<unsigned int>(Application::GetConcurrency()) / QUEUECOUNT, 4U);
if (alive + tthreads < ncput)
tthreads = ncput - alive;
#include "base/utility.hpp"
#include "base/logger.hpp"
#include "base/convert.hpp"
+#include "base/application.hpp"
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
}
ParallelWorkQueue::ParallelWorkQueue(void)
- : m_QueueCount(boost::thread::hardware_concurrency()),
+ : m_QueueCount(Application::GetConcurrency()),
m_Queues(new WorkQueue[m_QueueCount]),
m_Index(0)
{ }