SourceXtractorPlusPlus
0.13
Please provide a description of the project.
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
SEImplementation
src
lib
Configuration
MultiThreadingConfig.cpp
Go to the documentation of this file.
1
17
/*
18
* MultiThreadingConfig.cpp
19
*
20
* Created on: May 22, 2018
21
* Author: mschefer
22
*/
23
24
#include <boost/thread.hpp>
25
26
#include "
SEImplementation/Configuration/MultiThreadingConfig.h
"
27
28
using namespace
Euclid::Configuration;
29
namespace
po = boost::program_options;
30
31
namespace
SourceXtractor {
32
33
static
const
std::string
THREADS_NB
{
"thread-count"
};
34
35
MultiThreadingConfig::MultiThreadingConfig(
long
manager_id) :
Configuration
(manager_id), m_threads_nb(-1) {
36
}
37
38
auto
MultiThreadingConfig::getProgramOptions
() ->
std::map<std::string, OptionDescriptionList>
{
39
return
{ {
"Multi-threading"
, {
40
{
THREADS_NB
.
c_str
(), po::value<int>()->default_value(-1),
"Number of worker threads (-1=automatic, 0=disable all multithreading)"
}
41
}}};
42
}
43
44
void
MultiThreadingConfig::initialize
(
const
UserValues& args) {
45
m_threads_nb
= args.at(
THREADS_NB
).as<
int
>();
46
if
(
m_threads_nb
== -1) {
47
m_threads_nb
= boost::thread::hardware_concurrency();
48
}
49
else
if
(
m_threads_nb
< -1) {
50
throw
Elements::Exception
(
"Invalid number of threads."
);
51
}
52
m_thread_pool
= std::make_shared<Euclid::ThreadPool>(
m_threads_nb
);
53
}
54
55
}
// SourceXtractor namespace
56
SourceXtractor::MultiThreadingConfig::initialize
void initialize(const UserValues &args) override
Definition:
MultiThreadingConfig.cpp:44
SourceXtractor::THREADS_NB
static const std::string THREADS_NB
Definition:
MultiThreadingConfig.cpp:33
Euclid::Configuration::Configuration
SourceXtractor::MultiThreadingConfig::m_threads_nb
int m_threads_nb
Definition:
MultiThreadingConfig.h:51
std::map
STL class.
std::string
STL class.
Elements::Exception
SourceXtractor::MultiThreadingConfig::m_thread_pool
std::shared_ptr< Euclid::ThreadPool > m_thread_pool
Definition:
MultiThreadingConfig.h:52
MultiThreadingConfig.h
std::string::c_str
T c_str(T...args)
SourceXtractor::MultiThreadingConfig::getProgramOptions
std::map< std::string, OptionDescriptionList > getProgramOptions() override
Definition:
MultiThreadingConfig.cpp:38
Generated by
1.8.5