| The Gaudi Framework v27r1

- 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

`#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)
virtual tbb::task * | execute ()

## 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

Definition at line 14 of file ThreadInitTask.h.

## Constructor & Destructor Documentation

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

Definition at line 19 of file ThreadInitTask.h.

22 :
23 m_tools(tools), m_barrier(b), m_serviceLocator(svcLocator),
24 m_terminate(terminate){};
ThreadInitTask::m_serviceLocator
SmartIF< ISvcLocator > m_serviceLocator
Definition: ThreadInitTask.h:35
ThreadInitTask::m_tools
ToolHandleArray< IThreadInitTool > & m_tools
Definition: ThreadInitTask.h:32
ThreadInitTask::m_terminate
bool m_terminate
Definition: ThreadInitTask.h:36
ThreadInitTask::m_barrier
boost::barrier * m_barrier
Definition: ThreadInitTask.h:34

## Member Function Documentation

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

Definition at line 28 of file ThreadInitTask.h.

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

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

Definition at line 13 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()
22 << " at " << this
23 << std::dec << endmsg;
24
25 if (m_tools.retrieve().isFailure()) {
26 log << MSG::ERROR << "unable to retrieve ToolHandleArray " << m_tools
27 << endmsg;
28 m_execFailed = true;
29 } else {
30
31 if (m_tools.size() == 0) {
32 log << MSG::INFO << "no entries in Tool Array"
33 << endmsg;
34 } else {
35 if (debug)
36 log << MSG::DEBUG << "executing in thread 0x" << std::hex << pthread_self()
37 << std::dec << endmsg;
38
39 for ( auto t : m_tools ) {
40
41 try {
42
43 if (debug)
44 log << MSG::DEBUG << "calling IThreadInitTool " << t << endmsg;
45
46 if (!m_terminate) {
47 t->initThread();
48 } else {
49 t->terminateThread();
50 }
51
52 } catch( const GaudiException& exc ) {
53 log << MSG::ERROR << "ThreadInitTool " << t << " in thread 0x"
54 << std::hex << pthread_self() << std::dec << " threw GaudiException: "
55 << exc << endmsg;
56 m_execFailed = true;
57 } catch (const std::exception& exc ) {
58 log << MSG::ERROR << "ThreadInitTool " << t << " in thread 0x"
59 << std::hex << pthread_self() << std::dec << " threw std::exception: "
60 << exc.what() << endmsg;
61 m_execFailed = true;
62 } catch(...) {
63 log << MSG::ERROR << "ThreadInitTool " << t << " in thread 0x"
64 << std::hex << pthread_self() << std::dec << " threw unknown exception"
65 << endmsg;
66 m_execFailed = true;
67 }
68
69 }
70
71 m_tools.release().ignore();
72
73 }
74 }
75
76
77 if (m_barrier != 0) {
78 log << MSG::INFO << "waiting at barrier in thread 0x" << std::hex << pthread_self()
79 << std::dec << endmsg;
80 m_barrier->wait();
81 }
82
83 return nullptr;
84
85 }
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:23
ThreadInitTask::m_serviceLocator
SmartIF< ISvcLocator > m_serviceLocator
Definition: ThreadInitTask.h:35
Gaudi.Configuration.log
tuple log
Definition: Configuration.py:13
ThreadInitTask::m_execFailed
static std::atomic< bool > m_execFailed
Definition: ThreadInitTask.h:38
MSG::DEBUG
Definition: IMessageSvc.h:18
ThreadInitTask::m_tools
ToolHandleArray< IThreadInitTool > & m_tools
Definition: ThreadInitTask.h:32
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:517
std::exception::what
T what(T...args)
std::exception
STL class.
ThreadInitTask::m_terminate
bool m_terminate
Definition: ThreadInitTask.h:36
ThreadInitTask::m_barrier
boost::barrier * m_barrier
Definition: ThreadInitTask.h:34
std::hex
T hex(T...args)
MSG::ERROR
Definition: IMessageSvc.h:21
GaudiHandleArray::size
size_type size() const
Definition: GaudiHandle.h:472
MSG::INFO
Definition: IMessageSvc.h:19
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

## Member Data Documentation

boost::barrier* ThreadInitTask::m_barrier
| private

Definition at line 34 of file ThreadInitTask.h.

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

Definition at line 38 of file ThreadInitTask.h.

SmartIF<ISvcLocator> ThreadInitTask::m_serviceLocator
| private

Definition at line 35 of file ThreadInitTask.h.

bool ThreadInitTask::m_terminate
| private

Definition at line 36 of file ThreadInitTask.h.

ToolHandleArray<IThreadInitTool>& ThreadInitTask::m_tools
| private

Definition at line 32 of file ThreadInitTask.h.

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

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