| The Gaudi Framework v28r2p1 (f1a77ff4)

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

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Private Member Functions | Private Attributes | List of all members
ThreadPoolSvc Class Reference

A service which initializes a TBB thread pool. More...

`#include <src/ThreadPoolSvc.h>`

Inheritance diagram for ThreadPoolSvc:
[legend]
Collaboration diagram for ThreadPoolSvc:
[legend]

## Public Member Functions
| ThreadPoolSvc (const std::string &name, ISvcLocator *svc)
| Constructor. More...
virtual StatusCode | initialize () override final
| Initialise. More...
virtual StatusCode | finalize () override final
| Finalise. More...
virtual StatusCode | initPool (const int &poolSize) override final
| Initialize the thread pool and launch the ThreadInitTasks. More...
virtual StatusCode | terminatePool () override final
| Terminate the thread pool and launch thread termination tasks. More...
virtual int | poolSize () const override final
virtual bool | isInit () const
Public Member Functions inherited from extends< Service, IThreadPoolSvc >
void * | i_cast (const InterfaceID &tid) const override
| Implementation of IInterface::i_cast. More...
StatusCode | queryInterface (const InterfaceID &ti, void **pp) override
| Implementation of IInterface::queryInterface. More...
std::vector< std::string > | getInterfaceNames () const override
| Implementation of IInterface::getInterfaceNames. More...
| ~extends () override=default
| Virtual destructor. More...
Public Member Functions inherited from Service
const std::string & | name () const override
| Retrieve name of the service. More...
StatusCode | configure () override
StatusCode | initialize () override
StatusCode | start () override
StatusCode | stop () override
StatusCode | finalize () override
StatusCode | terminate () override
Gaudi::StateMachine::State | FSMState () const override
Gaudi::StateMachine::State | targetFSMState () const override
StatusCode | reinitialize () override
StatusCode | restart () override
StatusCode | sysInitialize () override
| Initialize Service. More...
StatusCode | sysStart () override
| Initialize Service. More...
StatusCode | sysStop () override
| Initialize Service. More...
StatusCode | sysFinalize () override
| Finalize Service. More...
StatusCode | sysReinitialize () override
| Re-initialize the Service. More...
StatusCode | sysRestart () override
| Re-initialize the Service. More...
| Service (std::string name, ISvcLocator *svcloc)
| Standard Constructor. More...
SmartIF< ISvcLocator > & | serviceLocator () const override
| Retrieve pointer to service locator. More...
StatusCode | setProperties ()
| Method for setting declared properties to the values specified for the job. More...
template<class T >
StatusCode | service (const std::string &name, const T *&psvc, bool createIf=true) const
| Access a service by name, creating it if it doesn't already exist. More...
template<class T >
StatusCode | service (const std::string &name, T *&psvc, bool createIf=true) const
template<typename IFace = IService>
SmartIF< IFace > | service (const std::string &name, bool createIf=true) const
template<class T >
StatusCode | service (const std::string &svcType, const std::string &svcName, T *&psvc) const
| Access a service by name and type, creating it if it doesn't already exist. More...
template<class T >
StatusCode | declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Private tool. More...
template<class T >
StatusCode | declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Public tool. More...
SmartIF< IAuditorSvc > & | auditorSvc () const
| The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
| PropertyHolder ()=default
| ~PropertyHolder () override=default
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Details::PropertyBase &prop)
| Declare a property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
| Helper to wrap a regular data member and use it as a regular property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none") const
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
| Declare a PropertyBase instance setting name and documentation. More...
Gaudi::Details::PropertyBase * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
| Declare a remote property. More...
StatusCode | setProperty (const Gaudi::Details::PropertyBase &p) override
| set the property form another property More...
StatusCode | setProperty (const std::string &s) override
| set the property from the formatted string More...
StatusCode | setProperty (const std::string &n, const std::string &v) override
| set the property from name and the value More...
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value More...
StatusCode | getProperty (Gaudi::Details::PropertyBase *p) const override
| get the property More...
const Gaudi::Details::PropertyBase & | getProperty (const std::string &name) const override
| get the property by name More...
StatusCode | getProperty (const std::string &n, std::string &v) const override
| convert the property to the string More...
const std::vector< Gaudi::Details::PropertyBase * > & | getProperties () const override
| get all properties More...
bool | hasProperty (const std::string &name) const override
| Return true if we have a property with the given name. More...
| PropertyHolder (const PropertyHolder &)=delete
PropertyHolder & | operator= (const PropertyHolder &)=delete
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
| Specializations for various GaudiHandles. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
Public Member Functions inherited from CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service. More...
MsgStream & | msgStream () const
| Return an uninitialized MsgStream. More...
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts. More...
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS) More...
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL) More...
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING) More...
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO) More...
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG) More...
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE) More...
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO) More...
MSG::Level | msgLevel () const
| get the output level from the embedded MsgStream More...
MSG::Level | outputLevel () const __attribute__((deprecated))
| Backward compatibility function for getting the output level. More...
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream More...
Public Member Functions inherited from extend_interfaces< Interfaces... >
| ~extend_interfaces () override=default
| Virtual destructor. More...

## Private Member Functions
StatusCode | launchTasks (bool finalize=false)
| Launch tasks to execute the ThreadInitTools. More...

## Private Attributes
ToolHandleArray< IThreadInitTool > | m_threadInitTools
| Handle array of thread init tools. More...
bool | m_init
| Was the thread pool initialized? More...
int | m_threadPoolSize
| Size of the thread pool allocated. More...
tbb::spin_mutex | m_initMutex
| Mutex used to protect the initPool and terminatePool methods. More...
std::unique_ptr< tbb::task_scheduler_init > | m_tbbSchedInit
| TBB task scheduler initializer. More...
std::unique_ptr< boost::barrier > | m_barrier
| Barrier used to synchronization thread init tasks. More...

## Additional Inherited Members
Public Types inherited from extends< Service, IThreadPoolSvc >
using | base_class = extends
| Typedef to this class. More...
using | extend_interfaces_base = extend_interfaces< Interfaces... >
| Typedef to the base of this class. More...
Public Types inherited from Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > | Factory
Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using | PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
| Typedef used to refer to this class from derived classes, as in. More...
Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using | base_class = CommonMessaging
Public Types inherited from extend_interfaces< Interfaces... >
using | ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
| take union of the ext_iids of all Interfaces... More...
Protected Member Functions inherited from Service
| ~Service () override
| Standard Destructor. More...
int | outputLevel () const
| get the `Service's` output level More...
Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBase * | property (const std::string &name) const
Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...
Protected Attributes inherited from Service
Gaudi::StateMachine::State | m_state = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::StateMachine::State | m_targetState = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::Property< int > | m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
Gaudi::Property< bool > | m_auditInit {this, "AuditServices", false, "[[deprecated]] unused"}
Gaudi::Property< bool > | m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
Gaudi::Property< bool > | m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
Gaudi::Property< bool > | m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
Gaudi::Property< bool > | m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
Gaudi::Property< bool > | m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
Gaudi::Property< bool > | m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
SmartIF< IAuditorSvc > | m_pAuditorSvc
| Auditor Service. More...

## Detailed Description

A service which initializes a TBB thread pool.

This service can be configured with an array of IThreadInitTools which will each be invoked concurrently on each worker thread. A ThreadInitTask is created for each thread and given the list of tools. A boost::barrier is used to synchronize the calling of each tool concurrently on all threads at the same time.

Definition at line 26 of file ThreadPoolSvc.h.

## Constructor & Destructor Documentation

ThreadPoolSvc::ThreadPoolSvc | ( | const std::string & | name,
|  | ISvcLocator * | svc
| ) |  |

Constructor.

Definition at line 20 of file ThreadPoolSvc.cpp.

20 :
21 base_class(name,svcLoc),
22 m_threadInitTools(this),
23 m_init(false),
24 m_threadPoolSize(0),
25 m_tbbSchedInit(nullptr),
26 m_barrier(nullptr)
27 {
28
29 declareProperty("ThreadInitTools", m_threadInitTools,
30 "ToolHandleArray of IThreadInitTools");
31
32 }
PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Details::PropertyBase &prop)
Declare a property.
Definition: PropertyHolder.h:99
extends< Service, IThreadPoolSvc >::base_class
extends base_class
Typedef to this class.
Definition: extends.h:14
ThreadPoolSvc::m_threadPoolSize
int m_threadPoolSize
Size of the thread pool allocated.
Definition: ThreadPoolSvc.h:62
ThreadPoolSvc::m_init
bool m_init
Was the thread pool initialized?
Definition: ThreadPoolSvc.h:59
ThreadPoolSvc::m_barrier
std::unique_ptr< boost::barrier > m_barrier
Barrier used to synchronization thread init tasks.
Definition: ThreadPoolSvc.h:71
ThreadPoolSvc::m_tbbSchedInit
std::unique_ptr< tbb::task_scheduler_init > m_tbbSchedInit
TBB task scheduler initializer.
Definition: ThreadPoolSvc.h:68
ThreadPoolSvc::m_threadInitTools
ToolHandleArray< IThreadInitTool > m_threadInitTools
Handle array of thread init tools.
Definition: ThreadPoolSvc.h:56

## Member Function Documentation

StatusCode ThreadPoolSvc::finalize | ( |  | ) |
| final override virtual

Finalise.

Definition at line 66 of file ThreadPoolSvc.cpp.

66 {
67
68 if (!m_init) {
69 warning() << "Looks like the ThreadPoolSvc was created, but thread pool "
70 << "was never initialized" << endmsg;
71 }
72
73 return StatusCode::SUCCESS;
74
75 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
ThreadPoolSvc::m_init
bool m_init
Was the thread pool initialized?
Definition: ThreadPoolSvc.h:59
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:120
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

StatusCode ThreadPoolSvc::initialize | ( |  | ) |
| final override virtual

Initialise.

Definition at line 37 of file ThreadPoolSvc.cpp.

37 {
38
39 // Initialise mother class (read properties, ...)
40 StatusCode sc(Service::initialize());
41 if (!sc.isSuccess()) {
42 warning () << "Base class could not be initialized" << endmsg;
43 return StatusCode::FAILURE;
44 }
45
46 if (m_threadInitTools.retrieve().isFailure()) {
47 error() << "Unable to retrieve ThreadInitTools Array" << endmsg;
48
49 return StatusCode::FAILURE;
50 } else {
51 if (m_threadInitTools.size() != 0) {
52 info() << "retrieved " << m_threadInitTools.size() << " thread init tools"
53 << endmsg;
54 } else {
55 info() << "no thread init tools attached" << endmsg;
56 }
57 }
58
59 return StatusCode::SUCCESS;
60
61 }
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:64
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode::FAILURE
Definition: StatusCode.h:29
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:123
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:84
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:117
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:120
GaudiHandleArray::retrieve
StatusCode retrieve()
Retrieve all tools.
Definition: GaudiHandle.h:561
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
GaudiHandleArray::size
size_type size() const
Definition: GaudiHandle.h:516
ThreadPoolSvc::m_threadInitTools
ToolHandleArray< IThreadInitTool > m_threadInitTools
Handle array of thread init tools.
Definition: ThreadPoolSvc.h:56
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

StatusCode ThreadPoolSvc::initPool | ( | const int & | poolSize | ) |
| final override virtual

Initialize the thread pool and launch the ThreadInitTasks.

Definition at line 80 of file ThreadPoolSvc.cpp.

80 {
81
82 tbb::spin_mutex::scoped_lock lock( m_initMutex );
83
84 m_threadPoolSize = poolSize;
85
86 if (msgLevel(MSG::DEBUG))
87 debug() << "ThreadPoolSvc::initPool() poolSize = " << poolSize << endmsg;
88 //There is a problem in the piece of the code below. if
89 // m_threadPoolSize is set to something negative which is < -1,
90 // algorithm below might not behave as expected. For the time being
91 // I've choosen to create the barrier with the default number of
92 // threads created by the task scheduler init assuming that a
93 // negative value will choose automatic thread creation which will
94 // create default number of threads.
95 // SK
96
97 // -100 prevents the creation of the pool and the scheduler directly
98 // executes the tasks.
99 if (-100 != m_threadPoolSize) {
100 if (msgLevel(MSG::DEBUG))
101 debug() << "Initialising a thread pool of size "
102 << m_threadPoolSize << endmsg;
103
104 // Leave -1 in case selected, increment otherwise
105 // - What?
106 int thePoolSize = m_threadPoolSize;
107 if (thePoolSize != -1) thePoolSize += 1;
108
109
110 // Create the TBB task scheduler
111 m_tbbSchedInit = std::unique_ptr<tbb::task_scheduler_init>( new tbb::task_scheduler_init(thePoolSize) );
112 // Create the barrier for task synchronization
113 if(m_threadPoolSize<=-1)thePoolSize=m_tbbSchedInit->default_num_threads();
114 if (msgLevel(MSG::DEBUG)){
115 debug() << "creating barrier of size " << thePoolSize << endmsg;
116 }
117 Gaudi::Concurrency::ConcurrencyFlags::setNumThreads(thePoolSize);
118
119 m_barrier = std::unique_ptr<boost::barrier>( new boost::barrier(thePoolSize) );
120
121 } else {
122 Gaudi::Concurrency::ConcurrencyFlags::setNumThreads(1);
123 }
124
125 // Launch the init tool tasks
126 const bool terminate = false;
127 if (launchTasks(terminate).isFailure())
128 return StatusCode::FAILURE;
129
130 if (msgLevel(MSG::DEBUG))
131 debug() << "Thread Pool initialization complete!" << endmsg;
132
133 m_init = true;
134
135 return StatusCode::SUCCESS;
136
137 }
Gaudi::Concurrency::ConcurrencyFlags::setNumThreads
static GAUDI_API void setNumThreads(const std::size_t &nT)
Definition: ConcurrencyFlags.h:54
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode::FAILURE
Definition: StatusCode.h:29
MSG::DEBUG
Definition: IMessageSvc.h:18
ThreadPoolSvc::m_threadPoolSize
int m_threadPoolSize
Size of the thread pool allocated.
Definition: ThreadPoolSvc.h:62
ThreadPoolSvc::m_init
bool m_init
Was the thread pool initialized?
Definition: ThreadPoolSvc.h:59
ThreadPoolSvc::poolSize
virtual int poolSize() const override final
Definition: ThreadPoolSvc.h:44
std::lock
T lock(T...args)
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 >
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:126
Service::terminate
StatusCode terminate() override
Definition: Service.h:53
ThreadPoolSvc::m_tbbSchedInit
std::unique_ptr< tbb::task_scheduler_init > m_tbbSchedInit
TBB task scheduler initializer.
Definition: ThreadPoolSvc.h:68
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
Definition: CommonMessaging.h:135
ThreadPoolSvc::launchTasks
StatusCode launchTasks(bool finalize=false)
Launch tasks to execute the ThreadInitTools.
Definition: ThreadPoolSvc.cpp:166
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

virtual bool ThreadPoolSvc::isInit | ( |  | ) | const
| inline virtual

Definition at line 48 of file ThreadPoolSvc.h.

48 { return m_init; }
ThreadPoolSvc::m_init
bool m_init
Was the thread pool initialized?
Definition: ThreadPoolSvc.h:59

StatusCode ThreadPoolSvc::launchTasks | ( | bool | finalize = `false` | ) |
| private

Launch tasks to execute the ThreadInitTools.

Definition at line 166 of file ThreadPoolSvc.cpp.

166 {
167
168 if (m_threadInitTools.empty()) return StatusCode::SUCCESS;
169
170 const std::string taskType = terminate ? "termination" : "initialization";
171
172 // If we have a thread pool (via a scheduler), then we want to queue
173 // the tasks in TBB to execute on each thread.
174 if(m_tbbSchedInit) {
175
176 // Create one task for each worker thread in the pool
177 for (int i = 0; i < m_threadPoolSize; ++i) {
178 if (msgLevel(MSG::DEBUG))
179 debug() << "creating ThreadInitTask " << i << endmsg;
180 tbb::task* t = new(tbb::task::allocate_root())
181 ThreadInitTask( m_threadInitTools, m_barrier.get(), serviceLocator(), terminate );
182
183 // Queue the task
184 tbb::task::enqueue( *t );
185 this_tbb_thread::sleep(tbb::tick_count::interval_t(.1));
186 }
187
188 // Now wait for all the workers to reach the barrier
189 if (msgLevel(MSG::DEBUG))
190 debug() << "waiting at barrier for all ThreadInitTool to finish executing" << endmsg;
191 m_barrier->wait();
192
193 // Check to make sure all Tools were invoked.
194 // I'm not sure this mechanism is worthwhile.
195 for (auto& t : m_threadInitTools) {
196 // Number of threads initialized but not terminated.
197 int numInit = t->nInit();
198 // Expected number based on the type of task.
199 int expectedNumInit = terminate? 0 : m_threadPoolSize;
200 if (numInit != expectedNumInit) {
201 error() << "not all threads " << (terminate? "terminated" : "initialized")
202 << " for tool " << t << " : "
203 << t->nInit() << " out of " << m_threadPoolSize
204 << " are currently active" << endmsg;
205 return StatusCode::FAILURE;
206 }
207 }
208
209 }
210
211 // In single-threaded mode, there is no scheduler, so we simply call
212 // the task wrapper directly in this thread.
213 else {
214 if (msgLevel(MSG::DEBUG))
215 debug() << "launching ThreadInitTask " << taskType << "in this thread." << endmsg;
216 boost::barrier* noBarrier = nullptr;
217 ThreadInitTask theTask(m_threadInitTools, noBarrier, serviceLocator(), terminate);
218 theTask.execute();
219 }
220
221 // Now, we do some error checking
222 if (ThreadInitTask::execFailed()) {
223 error() << "a ThreadInitTask failed to execute successfully" << endmsg;
224 return StatusCode::FAILURE;
225 }
226
227 return StatusCode::SUCCESS;
228 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode::FAILURE
Definition: StatusCode.h:29
MSG::DEBUG
Definition: IMessageSvc.h:18
ThreadInitTask
Special TBB task used by ThreadPoolSvc to wrap execution of IThreadInitTools.
Definition: ThreadInitTask.h:21
ThreadPoolSvc::m_threadPoolSize
int m_threadPoolSize
Size of the thread pool allocated.
Definition: ThreadPoolSvc.h:62
std::string
STL class.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:117
ThreadInitTask::execFailed
static bool execFailed()
Definition: ThreadInitTask.h:39
ThreadPoolSvc::m_barrier
std::unique_ptr< boost::barrier > m_barrier
Barrier used to synchronization thread init tasks.
Definition: ThreadPoolSvc.h:71
GaudiHandleArray::empty
bool empty() const override
Return whether the list of tools is empty.
Definition: GaudiHandle.h:524
std::unique_ptr::get
T get(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:126
Service::terminate
StatusCode terminate() override
Definition: Service.h:53
ThreadPoolSvc::m_tbbSchedInit
std::unique_ptr< tbb::task_scheduler_init > m_tbbSchedInit
TBB task scheduler initializer.
Definition: ThreadPoolSvc.h:68
ThreadPoolSvc::m_threadInitTools
ToolHandleArray< IThreadInitTool > m_threadInitTools
Handle array of thread init tools.
Definition: ThreadPoolSvc.h:56
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
Definition: CommonMessaging.h:135
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:292
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

virtual int ThreadPoolSvc::poolSize | ( |  | ) | const
| inline final override virtual

Definition at line 44 of file ThreadPoolSvc.h.

44 {
45 return m_threadPoolSize;
46 }
ThreadPoolSvc::m_threadPoolSize
int m_threadPoolSize
Size of the thread pool allocated.
Definition: ThreadPoolSvc.h:62

StatusCode ThreadPoolSvc::terminatePool | ( |  | ) |
| final override virtual

Terminate the thread pool and launch thread termination tasks.

Definition at line 142 of file ThreadPoolSvc.cpp.

142 {
143 tbb::spin_mutex::scoped_lock lock( m_initMutex );
144 if (msgLevel(MSG::DEBUG))
145 debug() << "ThreadPoolSvc::terminatePool()" << endmsg;
146
147 if (!m_init) {
148 error() << "Trying to terminate uninitialized thread pool!" << endmsg;
149 return StatusCode::FAILURE;
150 }
151
152 // Launch the termination tasks
153 const bool terminate = true;
154 if (launchTasks(terminate).isFailure())
155 return StatusCode::FAILURE;
156
157 if (msgLevel(MSG::DEBUG))
158 debug() << "Thread pool termination complete!" << endmsg;
159
160 return StatusCode::SUCCESS;
161 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode::FAILURE
Definition: StatusCode.h:29
MSG::DEBUG
Definition: IMessageSvc.h:18
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:117
ThreadPoolSvc::m_init
bool m_init
Was the thread pool initialized?
Definition: ThreadPoolSvc.h:59
std::lock
T lock(T...args)
ThreadPoolSvc::m_initMutex
tbb::spin_mutex m_initMutex
Mutex used to protect the initPool and terminatePool methods.
Definition: ThreadPoolSvc.h:65
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:126
Service::terminate
StatusCode terminate() override
Definition: Service.h:53
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
Definition: CommonMessaging.h:135
ThreadPoolSvc::launchTasks
StatusCode launchTasks(bool finalize=false)
Launch tasks to execute the ThreadInitTools.
Definition: ThreadPoolSvc.cpp:166
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

## Member Data Documentation

std::unique_ptr<boost::barrier> ThreadPoolSvc::m_barrier
| private

Barrier used to synchronization thread init tasks.

Definition at line 71 of file ThreadPoolSvc.h.

bool ThreadPoolSvc::m_init
| private

Was the thread pool initialized?

Definition at line 59 of file ThreadPoolSvc.h.

tbb::spin_mutex ThreadPoolSvc::m_initMutex
| private

Mutex used to protect the initPool and terminatePool methods.

Definition at line 65 of file ThreadPoolSvc.h.

std::unique_ptr<tbb::task_scheduler_init> ThreadPoolSvc::m_tbbSchedInit
| private

TBB task scheduler initializer.

Definition at line 68 of file ThreadPoolSvc.h.

ToolHandleArray<IThreadInitTool> ThreadPoolSvc::m_threadInitTools
| private

Handle array of thread init tools.

Definition at line 56 of file ThreadPoolSvc.h.

int ThreadPoolSvc::m_threadPoolSize
| private

Size of the thread pool allocated.

Definition at line 62 of file ThreadPoolSvc.h.

The documentation for this class was generated from the following files:

- GaudiHive/src/ThreadPoolSvc.h
- GaudiHive/src/ThreadPoolSvc.cpp