ATLAS Offline Software
Loading...
Searching...
No Matches
HiveAlgB.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "HiveAlgB.h"
6#include <thread>
7#include <chrono>
8#include <memory>
9
10HiveAlgB::HiveAlgB( const std::string& name,
11 ISvcLocator* pSvcLocator ) :
12 HiveAlgBase( name, pSvcLocator ),
13 m_di(0) {}
14
15HiveAlgB::~HiveAlgB() = default;
16
17/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
18
20 ATH_MSG_DEBUG("initialize " << name());
21
22 ATH_MSG_INFO("context: " << Gaudi::Hive::currentContext() << " for "
23 << this );
24
25 ATH_MSG_INFO(" m_di was: " << m_di << " setting to -1 ");
26 m_di = -1;
27
28 // dump out contents of context specific data
29 dump();
30
31 ATH_CHECK( m_wrh1.initialize() );
32
33 // initialize base class
35
36}
37
38/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
39
40StatusCode HiveAlgB::finalize() {
41 ATH_MSG_INFO("context: " << Gaudi::Hive::currentContext());
42 ATH_MSG_DEBUG("finalize " << name());
43
44 // dump out contents of context specific data
45 dump();
46
47 return StatusCode::SUCCESS;
48}
49
50/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
51
52StatusCode HiveAlgB::execute() {
53
54 ATH_MSG_DEBUG("execute " << name());
55
56 ATH_MSG_INFO("context: " << Gaudi::Hive::currentContext() << " for "
57 << this);
58
59 int s = sleep();
60
61 ATH_MSG_INFO("m_di was: " << m_di << " setting to " << s);
62 m_di = s;
63
65 ATH_CHECK(wrh1.record(std::make_unique< HiveDataObj >(20000)));
66
67 ATH_MSG_INFO(" write: " << wrh1.key() << " = " << wrh1->val() );
68
69 return StatusCode::SUCCESS;
70
71}
72
73/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
74
75void
77
78 std::ostringstream ost;
79
80 // use a lambda to access all constituents of context specific data
81 m_di.for_all([&ost] (size_t s, const int i)
82 { ost << " s: " << s << " v: " << i << std::endl; } );
83
84 ATH_MSG_INFO("dumping m_di: \n" << ost.str());
85
86}
87
88
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Simple Algorithm that writes a single HiveDataObj to the store.
SG::WriteHandleKey< HiveDataObj > m_wrh1
Definition HiveAlgB.h:42
HiveAlgB(const std::string &name, ISvcLocator *pSvcLocator)
Definition HiveAlgB.cxx:10
Gaudi::Hive::ContextSpecificData< int > m_di
Definition HiveAlgB.h:47
virtual StatusCode execute() override
Definition HiveAlgB.cxx:52
virtual StatusCode initialize() override
Definition HiveAlgB.cxx:19
virtual StatusCode finalize() override
Definition HiveAlgB.cxx:40
void dump()
Definition HiveAlgB.cxx:76
unsigned int sleep()
HiveAlgBase(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.