ATLAS Offline Software
AthenaSharedMemoryTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 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 <set>
18 #include <string>
19 
20 // Forward declarations.
21 class IIncidentSvc;
22 
23 namespace boost {
24  namespace interprocess {
25  class shared_memory_object;
26  class mapped_region;
27  }
28 }
29 
33 class AthenaSharedMemoryTool : public ::AthAlgTool, virtual public IAthenaIPCTool {
34 public:
36  AthenaSharedMemoryTool(const std::string& type, const std::string& name, const IInterface* parent);
38  virtual ~AthenaSharedMemoryTool();
39 
42  StatusCode stop();
44 
45  StatusCode makeServer(int num, const std::string& streamPortSuffix);
46  bool isServer() const;
47  StatusCode makeClient(int num, std::string& streamPortSuffix);
48  bool isClient() const;
49 
50  StatusCode putEvent ATLAS_NOT_THREAD_SAFE (long eventNumber, const void* source, size_t nbytes, unsigned int status) const;
51  StatusCode getLockedEvent(void** target, unsigned int& status) const;
52  StatusCode lockEvent(long eventNumber) const;
53 
54  StatusCode putObject(const void* source, size_t nbytes, int num = 0);
55  StatusCode getObject(void** target, size_t& nbytes, int num = 0);
56  StatusCode clearObject(const char** tokenString, int& num);
57  StatusCode lockObject(const char* tokenString, int num = 0);
58 
59 private:
60  StringProperty m_sharedMemory;
61  const size_t m_maxSize;
62  const int m_maxDataClients;
63  int m_num;
65  std::set<int> m_dataClients;
66  boost::interprocess::mapped_region* m_payload;
67  boost::interprocess::mapped_region* m_status;
69  bool m_isServer;
70  bool m_isClient;
72 };
73 
74 #endif
AthenaSharedMemoryTool::m_status
boost::interprocess::mapped_region * m_status
Definition: AthenaSharedMemoryTool.h:67
AthenaSharedMemoryTool::m_isServer
bool m_isServer
Definition: AthenaSharedMemoryTool.h:69
AthenaSharedMemoryTool::stop
StatusCode stop()
Definition: AthenaSharedMemoryTool.cxx:76
AthenaSharedMemoryTool::m_maxDataClients
const int m_maxDataClients
Definition: AthenaSharedMemoryTool.h:62
AthenaSharedMemoryTool::finalize
StatusCode finalize()
Definition: AthenaSharedMemoryTool.cxx:93
AthenaSharedMemoryTool::makeClient
StatusCode makeClient(int num, std::string &streamPortSuffix)
Definition: AthenaSharedMemoryTool.cxx:162
AthenaSharedMemoryTool::isServer
bool isServer() const
Definition: AthenaSharedMemoryTool.cxx:157
AthenaSharedMemoryTool::~AthenaSharedMemoryTool
virtual ~AthenaSharedMemoryTool()
Destructor.
Definition: AthenaSharedMemoryTool.cxx:55
AthenaSharedMemoryTool::getLockedEvent
StatusCode getLockedEvent(void **target, unsigned int &status) const
Definition: AthenaSharedMemoryTool.cxx:257
boost
Definition: DVLIterator.h:29
AthenaSharedMemoryTool::m_lastClient
int m_lastClient
Definition: AthenaSharedMemoryTool.h:64
AthenaSharedMemoryTool::putObject
StatusCode putObject(const void *source, size_t nbytes, int num=0)
Definition: AthenaSharedMemoryTool.cxx:303
AthenaSharedMemoryTool::makeServer
StatusCode makeServer(int num, const std::string &streamPortSuffix)
Definition: AthenaSharedMemoryTool.cxx:116
AthenaSharedMemoryTool::m_isClient
bool m_isClient
Definition: AthenaSharedMemoryTool.h:70
IAthenaIPCTool
Definition: IAthenaIPCTool.h:14
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
AthenaSharedMemoryTool::m_sharedMemory
StringProperty m_sharedMemory
Definition: AthenaSharedMemoryTool.h:60
AthAlgTool.h
AthenaSharedMemoryTool::m_dataClients
std::set< int > m_dataClients
Definition: AthenaSharedMemoryTool.h:65
AthenaSharedMemoryTool::clearObject
StatusCode clearObject(const char **tokenString, int &num)
Definition: AthenaSharedMemoryTool.cxx:376
test_pyathena.parent
parent
Definition: test_pyathena.py:15
AthenaSharedMemoryTool::m_payload
boost::interprocess::mapped_region * m_payload
Definition: AthenaSharedMemoryTool.h:66
AthenaSharedMemoryTool::getObject
StatusCode getObject(void **target, size_t &nbytes, int num=0)
Definition: AthenaSharedMemoryTool.cxx:344
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
AthenaSharedMemoryTool::ATLAS_NOT_THREAD_SAFE
StatusCode putEvent ATLAS_NOT_THREAD_SAFE(long eventNumber, const void *source, size_t nbytes, unsigned int status) const
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AthenaSharedMemoryTool::lockEvent
StatusCode lockEvent(long eventNumber) const
Definition: AthenaSharedMemoryTool.cxx:276
AthenaSharedMemoryTool::m_maxSize
const size_t m_maxSize
Definition: AthenaSharedMemoryTool.h:61
AthenaSharedMemoryTool::isClient
bool isClient() const
Definition: AthenaSharedMemoryTool.cxx:217
AthenaSharedMemoryTool::m_fileSeqNumber
long m_fileSeqNumber
Definition: AthenaSharedMemoryTool.h:68
copySelective.target
string target
Definition: copySelective.py:37
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
copySelective.source
string source
Definition: copySelective.py:32
AthenaSharedMemoryTool
This class provides the IPCTool for SharedMemory objects.
Definition: AthenaSharedMemoryTool.h:33
merge.status
status
Definition: merge.py:17
AthAlgTool
Definition: AthAlgTool.h:26
AthenaSharedMemoryTool::m_num
int m_num
Definition: AthenaSharedMemoryTool.h:63
AthenaSharedMemoryTool::lockObject
StatusCode lockObject(const char *tokenString, int num=0)
Definition: AthenaSharedMemoryTool.cxx:460
IAthenaIPCTool.h
AthenaSharedMemoryTool::initialize
StatusCode initialize()
Gaudi Service Interface method implementations:
Definition: AthenaSharedMemoryTool.cxx:61
AthenaSharedMemoryTool::m_incidentSvc
ServiceHandle< IIncidentSvc > m_incidentSvc
Definition: AthenaSharedMemoryTool.h:71
ServiceHandle< IIncidentSvc >