| The Gaudi Framework v29r0 (ff2e7097)

- 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 13 of file ThreadGaudi.h.

## Member Typedef Documentation

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

Definition at line 16 of file ThreadGaudi.h.

## Constructor & Destructor Documentation

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

Definition at line 84 of file ThreadGaudi.cpp.

84 : m_threadMap{new ThreadMap()} { ( *m_threadMap )[0] = ""; }
ThreadGaudi::m_threadMap
std::unique_ptr< ThreadMap > m_threadMap
Definition: ThreadGaudi.h:29
ThreadGaudi::ThreadMap
std::map< System::ThreadHandle, std::string > ThreadMap
Definition: ThreadGaudi.h:16

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

## Member Function Documentation

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

get Gaudi ID of current pthread

Definition at line 108 of file ThreadGaudi.cpp.

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

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

access the whole map

Definition at line 106 of file ThreadGaudi.cpp.

106 { return ThreadGaudi::instance()->m_threadMap.get(); }
ThreadGaudi::m_threadMap
std::unique_ptr< ThreadMap > m_threadMap
Definition: ThreadGaudi.h:29
ThreadGaudi::instance
static ThreadGaudi * instance()
singleton access
Definition: ThreadGaudi.cpp:86

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

singleton access

Definition at line 86 of file ThreadGaudi.cpp.

87 {
88 if ( !ThreadGaudiInstance ) ThreadGaudiInstance = new ThreadGaudi();
89 return ThreadGaudiInstance;
90 }
ThreadGaudiInstance
ThreadGaudi * ThreadGaudiInstance
Definition: ThreadGaudi.cpp:82
ThreadGaudi::ThreadGaudi
ThreadGaudi()
Definition: ThreadGaudi.cpp:84

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

associate Gaudi ID to pthread

Definition at line 92 of file ThreadGaudi.cpp.

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

## Member Data Documentation

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

Definition at line 29 of file ThreadGaudi.h.

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

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