| The Gaudi Framework v28r2-patches (bc4ad17a)

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

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

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ThreadGaudi Class Reference

singleton mapping the pthread ID to the Gaudi thread ID More...

`#include <GaudiKernel/ThreadGaudi.h>`

Collaboration diagram for ThreadGaudi:
[legend]

## Public Types
typedef std::map< System::ThreadHandle, std::string > | ThreadMap

## Public Member Functions
void | setThreadID (const std::string &threadID)
| associate Gaudi ID to pthread More...
ThreadMap * | getThreadMap ()
| access the whole map More...
const std::string & | getThreadID ()
| get Gaudi ID of current pthread More...

## Static Public Member Functions
static ThreadGaudi * | instance ()
| singleton access More...

## Protected Member Functions
| ThreadGaudi ()
virtual | ~ThreadGaudi ()=default

## Protected Attributes
std::unique_ptr< ThreadMap > | m_threadMap

## Detailed Description

singleton mapping the pthread ID to the Gaudi thread ID

Author
  Werner Wiedenmann

Definition at line 15 of file ThreadGaudi.h.

## Member Typedef Documentation

typedef std::map< System::ThreadHandle , std::string > ThreadGaudi::ThreadMap

Definition at line 17 of file ThreadGaudi.h.

## Constructor & Destructor Documentation

ThreadGaudi::ThreadGaudi | ( |  | ) |
| protected

Definition at line 83 of file ThreadGaudi.cpp.

83 :
84 m_threadMap{ new ThreadMap() }
85 {
86 (*m_threadMap)[0] = "" ;
87 }
ThreadGaudi::m_threadMap
std::unique_ptr< ThreadMap > m_threadMap
Definition: ThreadGaudi.h:30
ThreadGaudi::ThreadMap
std::map< System::ThreadHandle, std::string > ThreadMap
Definition: ThreadGaudi.h:17

virtual ThreadGaudi::~ThreadGaudi | ( |  | ) |
| protected virtual default

## Member Function Documentation

const std::string & ThreadGaudi::getThreadID | ( |  | ) |

get Gaudi ID of current pthread

Definition at line 111 of file ThreadGaudi.cpp.

111 {
112 ThreadMap* p_threadMap = getThreadMap() ;
113 System::ThreadHandle s_pid = System::threadSelf() ;
114 if ( p_threadMap->find(s_pid) != p_threadMap->end() ) {
115 return (*p_threadMap->find(s_pid)).second ;
116 } else {
117 return (*p_threadMap->find(0)).second ; ;
118 }
119 }
System::ThreadHandle
void * ThreadHandle
A Thread handle.
Definition: System.h:110
ThreadGaudi::ThreadMap
std::map< System::ThreadHandle, std::string > ThreadMap
Definition: ThreadGaudi.h:17
Gaudi::Units::second
constexpr double second
Definition: SystemOfUnits.h:122
ThreadGaudi::getThreadMap
ThreadMap * getThreadMap()
access the whole map
Definition: ThreadGaudi.cpp:107
System::threadSelf
ThreadHandle threadSelf()
thread handle "accessor"
Definition: System.h:112

ThreadGaudi::ThreadMap * ThreadGaudi::getThreadMap | ( |  | ) |

access the whole map

Definition at line 107 of file ThreadGaudi.cpp.

107 {
108 return ThreadGaudi::instance()->m_threadMap.get();
109 }
ThreadGaudi::m_threadMap
std::unique_ptr< ThreadMap > m_threadMap
Definition: ThreadGaudi.h:30
ThreadGaudi::instance
static ThreadGaudi * instance()
singleton access
Definition: ThreadGaudi.cpp:90

ThreadGaudi * ThreadGaudi::instance | ( |  | ) |
| static

singleton access

Definition at line 90 of file ThreadGaudi.cpp.

90 {
91 if ( !ThreadGaudiInstance ) ThreadGaudiInstance = new ThreadGaudi();
92 return ThreadGaudiInstance ;
93 }
ThreadGaudiInstance
ThreadGaudi * ThreadGaudiInstance
Definition: ThreadGaudi.cpp:81
ThreadGaudi::ThreadGaudi
ThreadGaudi()
Definition: ThreadGaudi.cpp:83

void ThreadGaudi::setThreadID | ( | const std::string & | threadID | ) |

associate Gaudi ID to pthread

Definition at line 95 of file ThreadGaudi.cpp.

95 {
96 ThreadMap* p_threadMap = getThreadMap() ;
97 // get from name thread ID
98 System::ThreadHandle s_pid = System::threadSelf() ;
99 if (p_threadMap->count(s_pid) == 0 ) {
100 (*p_threadMap)[s_pid] = threadID ;
101 #ifdef THREAD_GAUDI__DEBUG
102 std::cout << " *** ThreadGaudi setThreadID *** value set for *** " << threadID << " thread ID : " << s_pid << std::endl ;
103 #endif
104 }
105 }
System::ThreadHandle
void * ThreadHandle
A Thread handle.
Definition: System.h:110
std::endl
T endl(T...args)
ThreadGaudi::ThreadMap
std::map< System::ThreadHandle, std::string > ThreadMap
Definition: ThreadGaudi.h:17
ThreadGaudi::getThreadMap
ThreadMap * getThreadMap()
access the whole map
Definition: ThreadGaudi.cpp:107
System::threadSelf
ThreadHandle threadSelf()
thread handle "accessor"
Definition: System.h:112
std::cout

## Member Data Documentation

std::unique_ptr<ThreadMap> ThreadGaudi::m_threadMap
| protected

Definition at line 30 of file ThreadGaudi.h.

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

- GaudiKernel/GaudiKernel/ThreadGaudi.h
- GaudiKernel/src/Lib/ThreadGaudi.cpp