| The Gaudi Framework v28r2p1 (f1a77ff4)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

ThreadPoolSvc.h
Go to the documentation of this file.
1 #ifndef GAUDIHIVE_THREADPOOLSVC_H
2 #define GAUDIHIVE_THREADPOOLSVC_H
3
4 #include "GaudiKernel/Service.h"
5 #include "GaudiKernel/IThreadPoolSvc.h"
6 #include "GaudiKernel/IThreadInitTool.h"
7 #include "GaudiKernel/ToolHandle.h"
8
9 #include "tbb/spin_mutex.h"
10 #include "tbb/task_scheduler_init.h"
11 #include "boost/thread.hpp"
12
13 #include <vector>
14 #include <memory>
15
26 class ThreadPoolSvc: public extends<Service,
27 IThreadPoolSvc> {
28 public:
30 ThreadPoolSvc( const std::string& name, ISvcLocator* svc );
31
33 virtual StatusCode initialize() override final;
34
36 virtual StatusCode finalize() override final;
37
39 virtual StatusCode initPool(const int& poolSize) override final;
40
42 virtual StatusCode terminatePool() override final;
43
44 virtual int poolSize() const override final {
45 return m_threadPoolSize;
46 }
47
48 virtual bool isInit() const { return m_init; }
49
50 private:
51
53 StatusCode launchTasks(bool finalize=false);
54
56 ToolHandleArray<IThreadInitTool> m_threadInitTools;
57
59 bool m_init;
60
62 int m_threadPoolSize;
63
65 tbb::spin_mutex m_initMutex;
66
68 std::unique_ptr<tbb::task_scheduler_init> m_tbbSchedInit;
69
71 std::unique_ptr<boost::barrier> m_barrier;
72
73 };
74
75 #endif
ThreadPoolSvc::finalize
virtual StatusCode finalize() override final
Finalise.
Definition: ThreadPoolSvc.cpp:66
ThreadPoolSvc::ThreadPoolSvc
ThreadPoolSvc(const std::string &name, ISvcLocator *svc)
Constructor.
Definition: ThreadPoolSvc.cpp:20
IThreadPoolSvc.h
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
ThreadPoolSvc::terminatePool
virtual StatusCode terminatePool() override final
Terminate the thread pool and launch thread termination tasks.
Definition: ThreadPoolSvc.cpp:142
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
ThreadPoolSvc::isInit
virtual bool isInit() const
Definition: ThreadPoolSvc.h:48
ToolHandleArray< IThreadInitTool >
ThreadPoolSvc::m_threadPoolSize
int m_threadPoolSize
Size of the thread pool allocated.
Definition: ThreadPoolSvc.h:62
std::string
STL class.
Service.h
ThreadPoolSvc::m_init
bool m_init
Was the thread pool initialized?
Definition: ThreadPoolSvc.h:59
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
ThreadPoolSvc::poolSize
virtual int poolSize() const override final
Definition: ThreadPoolSvc.h:44
ThreadPoolSvc::initialize
virtual StatusCode initialize() override final
Initialise.
Definition: ThreadPoolSvc.cpp:37
ThreadPoolSvc::m_barrier
std::unique_ptr< boost::barrier > m_barrier
Barrier used to synchronization thread init tasks.
Definition: ThreadPoolSvc.h:71
ThreadPoolSvc::m_initMutex
tbb::spin_mutex m_initMutex
Mutex used to protect the initPool and terminatePool methods.
Definition: ThreadPoolSvc.h:65
std::unique_ptr< tbb::task_scheduler_init >
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
ThreadPoolSvc
A service which initializes a TBB thread pool.
Definition: ThreadPoolSvc.h:26
ToolHandle.h
ThreadPoolSvc::m_tbbSchedInit
std::unique_ptr< tbb::task_scheduler_init > m_tbbSchedInit
TBB task scheduler initializer.
Definition: ThreadPoolSvc.h:68
ThreadPoolSvc::initPool
virtual StatusCode initPool(const int &poolSize) override final
Initialize the thread pool and launch the ThreadInitTasks.
Definition: ThreadPoolSvc.cpp:80
ThreadPoolSvc::m_threadInitTools
ToolHandleArray< IThreadInitTool > m_threadInitTools
Handle array of thread init tools.
Definition: ThreadPoolSvc.h:56
IThreadInitTool.h
ThreadPoolSvc::launchTasks
StatusCode launchTasks(bool finalize=false)
Launch tasks to execute the ThreadInitTools.
Definition: ThreadPoolSvc.cpp:166