ATLAS Offline Software
AthenaSharedMemoryTool.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 ATHENASHAREDMEMORYTOOL_H
6 #define ATHENASHAREDMEMORYTOOL_H
7 
13 #include "GaudiKernel/ServiceHandle.h"
16 
17 #include <memory>
18 #include <set>
19 #include <string>
20 
21 // Forward declarations.
22 class IIncidentSvc;
23 
24 namespace boost {
25  namespace interprocess {
26  class shared_memory_object;
27  class mapped_region;
28  }
29 }
30 
34 class AthenaSharedMemoryTool : public extends<::AthAlgTool, IAthenaIPCTool> {
35 public:
37  AthenaSharedMemoryTool(const std::string& type, const std::string& name, const IInterface* parent);
39  virtual ~AthenaSharedMemoryTool();
40 
42  virtual StatusCode initialize() override;
43  virtual StatusCode stop() override;
44  virtual StatusCode finalize() override;
45 
46  virtual StatusCode makeServer(int num, const std::string& streamPortSuffix) override;
47  virtual bool isServer() const override;
48  virtual StatusCode makeClient(int num, std::string& streamPortSuffix) override;
49  virtual bool isClient() const override;
50 
51  virtual StatusCode putEvent ATLAS_NOT_THREAD_SAFE (long eventNumber, const void* source, size_t nbytes, unsigned int status) const override;
52  virtual StatusCode getLockedEvent(void** target, unsigned int& status) const override;
53  virtual StatusCode lockEvent(long eventNumber) const override;
54 
55  virtual StatusCode putObject(const void* source, size_t nbytes, int num = 0) override;
56  virtual StatusCode getObject(void** target, size_t& nbytes, int num = 0) override;
57  virtual StatusCode clearObject(const char** tokenString, int& num) override;
58  virtual StatusCode lockObject(const char* tokenString, int num = 0) override;
59 
60 private:
61  Gaudi::Property<std::string> m_sharedMemory{this, "SharedMemoryName", {}};
62 
63  const size_t m_maxSize{64 * 1024 * 1024};
64  const int m_maxDataClients{256};
65  int m_num{-1};
66  int m_lastClient{-1};
67  std::set<int> m_dataClients;
68  std::unique_ptr<boost::interprocess::mapped_region> m_payload;
69  std::unique_ptr<boost::interprocess::mapped_region> m_status;
70  long m_fileSeqNumber{0};
71  bool m_isServer{false};
72  bool m_isClient{false};
74 };
75 
76 #endif
AthenaSharedMemoryTool::m_isServer
bool m_isServer
Definition: AthenaSharedMemoryTool.h:71
AthenaSharedMemoryTool::clearObject
virtual StatusCode clearObject(const char **tokenString, int &num) override
Definition: AthenaSharedMemoryTool.cxx:358
AthenaSharedMemoryTool::putObject
virtual StatusCode putObject(const void *source, size_t nbytes, int num=0) override
Definition: AthenaSharedMemoryTool.cxx:285
AthenaSharedMemoryTool::m_maxDataClients
const int m_maxDataClients
Definition: AthenaSharedMemoryTool.h:64
AthenaSharedMemoryTool::ATLAS_NOT_THREAD_SAFE
virtual StatusCode putEvent ATLAS_NOT_THREAD_SAFE(long eventNumber, const void *source, size_t nbytes, unsigned int status) const override
AthenaSharedMemoryTool::~AthenaSharedMemoryTool
virtual ~AthenaSharedMemoryTool()
Destructor.
Definition: AthenaSharedMemoryTool.cxx:45
AthenaSharedMemoryTool::lockEvent
virtual StatusCode lockEvent(long eventNumber) const override
Definition: AthenaSharedMemoryTool.cxx:258
AthenaSharedMemoryTool::makeClient
virtual StatusCode makeClient(int num, std::string &streamPortSuffix) override
Definition: AthenaSharedMemoryTool.cxx:144
AthenaSharedMemoryTool::getLockedEvent
virtual StatusCode getLockedEvent(void **target, unsigned int &status) const override
Definition: AthenaSharedMemoryTool.cxx:239
boost
Definition: DVLIterator.h:29
AthenaSharedMemoryTool::isServer
virtual bool isServer() const override
Definition: AthenaSharedMemoryTool.cxx:139
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
AthenaSharedMemoryTool::m_lastClient
int m_lastClient
Definition: AthenaSharedMemoryTool.h:66
AthenaSharedMemoryTool::finalize
virtual StatusCode finalize() override
Definition: AthenaSharedMemoryTool.cxx:75
AthenaSharedMemoryTool::lockObject
virtual StatusCode lockObject(const char *tokenString, int num=0) override
Definition: AthenaSharedMemoryTool.cxx:442
AthenaSharedMemoryTool::m_isClient
bool m_isClient
Definition: AthenaSharedMemoryTool.h:72
AthenaSharedMemoryTool::initialize
virtual StatusCode initialize() override
Gaudi Service Interface method implementations:
Definition: AthenaSharedMemoryTool.cxx:49
AthenaSharedMemoryTool::AthenaSharedMemoryTool
AthenaSharedMemoryTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Service Constructor.
Definition: AthenaSharedMemoryTool.cxx:36
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthAlgTool.h
AthenaSharedMemoryTool::m_dataClients
std::set< int > m_dataClients
Definition: AthenaSharedMemoryTool.h:67
test_pyathena.parent
parent
Definition: test_pyathena.py:15
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
AthenaSharedMemoryTool::m_status
std::unique_ptr< boost::interprocess::mapped_region > m_status
Definition: AthenaSharedMemoryTool.h:69
AthenaSharedMemoryTool::stop
virtual StatusCode stop() override
Definition: AthenaSharedMemoryTool.cxx:58
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
AthenaSharedMemoryTool::m_maxSize
const size_t m_maxSize
Definition: AthenaSharedMemoryTool.h:63
AthenaSharedMemoryTool::m_fileSeqNumber
long m_fileSeqNumber
Definition: AthenaSharedMemoryTool.h:70
AthenaSharedMemoryTool::isClient
virtual bool isClient() const override
Definition: AthenaSharedMemoryTool.cxx:199
copySelective.target
string target
Definition: copySelective.py:36
AthenaSharedMemoryTool::makeServer
virtual StatusCode makeServer(int num, const std::string &streamPortSuffix) override
Definition: AthenaSharedMemoryTool.cxx:98
copySelective.source
string source
Definition: copySelective.py:31
AthenaSharedMemoryTool
This class provides the IPCTool for SharedMemory objects.
Definition: AthenaSharedMemoryTool.h:34
merge.status
status
Definition: merge.py:16
AthenaSharedMemoryTool::m_sharedMemory
Gaudi::Property< std::string > m_sharedMemory
Definition: AthenaSharedMemoryTool.h:61
AthenaSharedMemoryTool::getObject
virtual StatusCode getObject(void **target, size_t &nbytes, int num=0) override
Definition: AthenaSharedMemoryTool.cxx:326
AthenaSharedMemoryTool::m_num
int m_num
Definition: AthenaSharedMemoryTool.h:65
IAthenaIPCTool.h
AthenaSharedMemoryTool::m_incidentSvc
ServiceHandle< IIncidentSvc > m_incidentSvc
Definition: AthenaSharedMemoryTool.h:73
ServiceHandle< IIncidentSvc >
AthenaSharedMemoryTool::m_payload
std::unique_ptr< boost::interprocess::mapped_region > m_payload
Definition: AthenaSharedMemoryTool.h:68