| The Gaudi Framework v29r0 (ff2e7097)

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

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

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

Special TBB task used by ThreadPoolSvc to wrap execution of IThreadInitTools. More...

`#include <src/ThreadInitTask.h>`

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

## Public Member Functions
| ThreadInitTask (ToolHandleArray< IThreadInitTool > &tools, boost::barrier *b, ISvcLocator *svcLocator, bool terminate=false)
tbb::task * | execute () override
| Execute the task. More...

## Static Public Member Functions
static bool | execFailed ()

## Private Attributes
ToolHandleArray< IThreadInitTool > & | m_tools
boost::barrier * | m_barrier
SmartIF< ISvcLocator > | m_serviceLocator
bool | m_terminate

## Static Private Attributes
static std::atomic< bool > | m_execFailed

## Detailed Description

Special TBB task used by ThreadPoolSvc to wrap execution of IThreadInitTools.

Author
  Charles Leggett

Definition at line 21 of file ThreadInitTask.h.

## Constructor & Destructor Documentation

ThreadInitTask::ThreadInitTask | ( | ToolHandleArray< IThreadInitTool > & | tools,
|  | boost::barrier * | b,
|  | ISvcLocator * | svcLocator,
|  | bool | terminate = `false`
| ) |  |
| inline

Definition at line 26 of file ThreadInitTask.h.

28 : m_tools( tools ), m_barrier( b ), m_serviceLocator( svcLocator ), m_terminate( terminate ){};
ThreadInitTask::m_serviceLocator
SmartIF< ISvcLocator > m_serviceLocator
Definition: ThreadInitTask.h:42
ThreadInitTask::m_tools
ToolHandleArray< IThreadInitTool > & m_tools
Definition: ThreadInitTask.h:39
ThreadInitTask::m_terminate
bool m_terminate
Definition: ThreadInitTask.h:43
ThreadInitTask::m_barrier
boost::barrier * m_barrier
Definition: ThreadInitTask.h:41

## Member Function Documentation

static bool ThreadInitTask::execFailed | ( |  | ) |
| inline static

Definition at line 36 of file ThreadInitTask.h.

36 { return m_execFailed; }
ThreadInitTask::m_execFailed
static std::atomic< bool > m_execFailed
Definition: ThreadInitTask.h:45

tbb::task * ThreadInitTask::execute | ( |  | ) |
| override

Execute the task.

Will loop over IThreadInitTools and execute each one.

Definition at line 12 of file ThreadInitTask.cpp.

13 {
14
15 SmartIF<IMessageSvc> messageSvc( m_serviceLocator );
16 MsgStream log( messageSvc, "ThreadInitTask" );
17
18 const auto debug = log.level() <= MSG::DEBUG;
19
20 if ( debug )
21 log << MSG::DEBUG << "execute in thread 0x" << std::hex << pthread_self() << " at " << this << std::dec << endmsg;
22
23 if ( m_tools.retrieve().isFailure() ) {
24 log << MSG::ERROR << "unable to retrieve ToolHandleArray " << m_tools << endmsg;
25 m_execFailed = true;
26 } else {
27
28 if ( m_tools.size() == 0 ) {
29 log << MSG::INFO << "no entries in Tool Array" << endmsg;
30 } else {
31 if ( debug ) log << MSG::DEBUG << "executing in thread 0x" << std::hex << pthread_self() << std::dec << endmsg;
32
33 for ( auto& t : m_tools ) {
34
35 try {
36
37 if ( debug ) log << MSG::DEBUG << "calling IThreadInitTool " << t << endmsg;
38
39 if ( !m_terminate ) {
40 t->initThread();
41 } else {
42 t->terminateThread();
43 }
44
45 } catch ( const GaudiException& exc ) {
46 log << MSG::ERROR << "ThreadInitTool " << t << " in thread 0x" << std::hex << pthread_self() << std::dec
47 << " threw GaudiException: " << exc << endmsg;
48 m_execFailed = true;
49 } catch ( const std::exception& exc ) {
50 log << MSG::ERROR << "ThreadInitTool " << t << " in thread 0x" << std::hex << pthread_self() << std::dec
51 << " threw std::exception: " << exc.what() << endmsg;
52 m_execFailed = true;
53 } catch ( ... ) {
54 log << MSG::ERROR << "ThreadInitTool " << t << " in thread 0x" << std::hex << pthread_self() << std::dec
55 << " threw unknown exception" << endmsg;
56 m_execFailed = true;
57 }
58 }
59
60 m_tools.release().ignore();
61 }
62 }
63
64 if ( m_barrier != 0 ) {
65 log << MSG::INFO << "waiting at barrier in thread 0x" << std::hex << pthread_self() << std::dec << endmsg;
66 m_barrier->wait();
67 }
68
69 return nullptr;
70 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
SmartIF< IMessageSvc >
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:22
ThreadInitTask::m_serviceLocator
SmartIF< ISvcLocator > m_serviceLocator
Definition: ThreadInitTask.h:42
ThreadInitTask::m_execFailed
static std::atomic< bool > m_execFailed
Definition: ThreadInitTask.h:45
MSG::DEBUG
Definition: IMessageSvc.h:16
ThreadInitTask::m_tools
ToolHandleArray< IThreadInitTool > & m_tools
Definition: ThreadInitTask.h:39
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
GaudiHandleArray::retrieve
StatusCode retrieve()
Retrieve all tools.
Definition: GaudiHandle.h:528
std::exception::what
T what(T...args)
std::exception
STL class.
ThreadInitTask::m_terminate
bool m_terminate
Definition: ThreadInitTask.h:43
ThreadInitTask::m_barrier
boost::barrier * m_barrier
Definition: ThreadInitTask.h:41
std::hex
T hex(T...args)
MSG::ERROR
Definition: IMessageSvc.h:16
GaudiHandleArray::size
size_type size() const
Definition: GaudiHandle.h:494
MSG::INFO
Definition: IMessageSvc.h:16
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi.Configuration.log
log
Definition: Configuration.py:13

## Member Data Documentation

boost::barrier* ThreadInitTask::m_barrier
| private

Definition at line 41 of file ThreadInitTask.h.

std::atomic< bool > ThreadInitTask::m_execFailed
| static private

Definition at line 45 of file ThreadInitTask.h.

SmartIF<ISvcLocator> ThreadInitTask::m_serviceLocator
| private

Definition at line 42 of file ThreadInitTask.h.

bool ThreadInitTask::m_terminate
| private

Definition at line 43 of file ThreadInitTask.h.

ToolHandleArray<IThreadInitTool>& ThreadInitTask::m_tools
| private

Definition at line 39 of file ThreadInitTask.h.

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

- GaudiHive/src/ThreadInitTask.h
- GaudiHive/src/ThreadInitTask.cpp