ATLAS Offline Software
Loading...
Searching...
No Matches
ThreadInitTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ATHEXHIVE_THREADINITTOOL_H
6#define ATHEXHIVE_THREADINITTOOL_H
7
9#include "GaudiKernel/IThreadInitTool.h"
10
11#include <string>
12#include <atomic>
13
14//-------------------------------------------------------------------------------
15//
16// This is an example of a Tool that will get executed in every thread by the
17// ThreadPoolSvc.
18//
19// At the beginning of the job, just after the ThreadPool has been created,
20// the initThread() method of the Tool will be called in each thread.
21//
22// as a check, m_nInitThreads MUST be incremented at the end of the initThread()
23// method.
24//
25// At the end of the job, the terminateThread() method will be called.
26//
27//-------------------------------------------------------------------------------
28
29
30class ThreadInitTool: virtual public extends<AthAlgTool, IThreadInitTool> {
31
32public:
33 ThreadInitTool( const std::string&, const std::string&, const IInterface* );
34
35
36 virtual void initThread() override;
37 virtual void terminateThread() override;
38
39 virtual unsigned int nInit() const override { return m_nInitThreads; }
40
41private:
42 // Number of threads that have been initialized
43 std::atomic_uint m_nInitThreads{0};
44
45};
46
47#endif
ThreadInitTool(const std::string &, const std::string &, const IInterface *)
virtual void initThread() override
virtual void terminateThread() override
virtual unsigned int nInit() const override
std::atomic_uint m_nInitThreads