15 #ifndef MULTITHREADING_HELPERS_HPP 16 #define MULTITHREADING_HELPERS_HPP 37 template<
class SingleThreadedFunctorT,
class MultiThreadedFunctorT>
43 unsigned threadcount_;
47 SingleThreadedFunctorT sf_;
48 MultiThreadedFunctorT mtf_;
61 LINFO (
"Multithreading:" << threadcount_ <<
" threads" );
63 LINFO (
"Multithreading: no" );
68 inline void operator() () {
69 if ( multithread_ ) mtf_ ( rg_, threadcount_ );
83 template<
class SingleThreadedFunctorT,
class MultiThreadedFunctorT >
101 if ( multithread_ ) {
102 LINFO (
"Multithreading:yes" );
104 LINFO (
"Multithreading:no" );
109 inline void operator() () {
110 if ( multithread_ ) {
111 MultiThreadedFunctorT mtf ( rg_ );
115 SingleThreadedFunctorT sf ( rg_ );
129 template<
class SingleThreadedFunctorT,
class MultiThreadedFunctorT,
class ServerFunctorT >
151 LINFO (
"Initializing server..." );
152 }
else if ( multithread_ ) {
153 LINFO (
"Multithreading:yes" );
155 LINFO (
"Multithreading:no" );
160 inline void operator() () {
162 ServerFunctorT serv ( rg_ );
166 if ( multithread_ ) {
167 MultiThreadedFunctorT mtf ( rg_ );
171 SingleThreadedFunctorT sf ( rg_ );
const std::string kServerEnable
Convenience wrapper class that can kick off three type of executions: singlethreaded, multithreaded, or server, triggered by program options. Possibly multithreading with 1 thread would do, but I keep both implementations as any plain bug that might arise will be easier to trace down with a single thread execution. The class is templated three functors, one for each type of execution Note that the details are up to the each of these functors.
Runner3(const RegistryPO &rg)
Constructor.
Convenience wrapper class that can kick off two type of executions: singlethreaded or multithreaded...
bool exists(const std::string &source, const std::string &needle)
Convenience function to find out whether a needle exists in a text.
const std::string kNThreads
Runner(const RegistryPO &rg)
Constructor.
Implements trivial threadpool using boost::asio library.
Runner2(const RegistryPO &rg)
Constructor.
Convenience wrapper class that can kick off two type of executions: single or multithreaded, triggered by program options. Possibly multithreading with 1 thread would do, but I keep both implementations as any plain bug that might arise will be easier to trace down with a serialized execution (threadpool uses two, actually). The class is templated with two classes, one for single threading and another for multithreading. Note that the multithreading details are up to the second templated class.