ATLAS Offline Software
T2pMap.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 
3 /*
4  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef SGTOOLS_T2PMAP_H
8 #define SGTOOLS_T2PMAP_H
9 
10 #include "SGTools/ptrhash.h"
11 #include <utility>
12 #include <vector>
13 #include <unordered_map>
14 #include <mutex>
16 
17 namespace SG {
18 
19 class DataProxy;
20 
21 class T2pMap {
22 
23  public:
24 
25  typedef std::unordered_map<const void*, DataProxy*, ptrhash> t2p;
26 
27  // constructor
28  T2pMap(IPageAccessControlSvc* pac=0) : m_pac(pac) { };
29 
30  // Destructor
31  ~T2pMap() { };
32 
33  // associate a void* (T*) with a proxy
34  bool t2pRegister(const void* const pTrans, DataProxy* const pPers) {
35  std::lock_guard<std::mutex> lock (m_mutex);
36  bool success(m_t2p.insert (std::make_pair (pTrans, pPers)) . second);
37  if (m_pac) m_pac->controlPage(pTrans);
38  return success;
39  }
40 
41  // locate a proxy in t2p map
42  DataProxy* locatePersistent(const void* const pTransient) const {
43  std::lock_guard<std::mutex> lock (m_mutex);
44  t2p::const_iterator i = m_t2p.find(pTransient);
45 
46  if (i == m_t2p.end())
47  return 0;
48  else
49  return i->second;
50  }
51 
52  // clear the t2p map
53  void clear() {
54  std::lock_guard<std::mutex> lock (m_mutex);
55  m_t2p.clear();
56  }
57 
58  // remove a void* from t2p
59  void t2pRemove(const void* const pTrans) {
60  std::lock_guard<std::mutex> lock (m_mutex);
61  m_t2p.erase(pTrans);
62  }
63 
65  void setPac(IPageAccessControlSvc* pac) { m_pac=pac; }
67  std::vector<const DataProxy*> pacReport() const;
68 
69 
70  private:
74 };
75 
76 }
77 #endif
SG::T2pMap::setPac
void setPac(IPageAccessControlSvc *pac)
set IPageAccessControlSvc ptr in T2PMap
Definition: T2pMap.h:65
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
SG::T2pMap::~T2pMap
~T2pMap()
Definition: T2pMap.h:31
SG::T2pMap::t2p
std::unordered_map< const void *, DataProxy *, ptrhash > t2p
Definition: T2pMap.h:25
IPageAccessControlSvc.h
Interface to a service that monitors memory page accesses.
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::T2pMap::locatePersistent
DataProxy * locatePersistent(const void *const pTransient) const
Definition: T2pMap.h:42
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
SG::T2pMap::T2pMap
T2pMap(IPageAccessControlSvc *pac=0)
Definition: T2pMap.h:28
ptrhash.h
Improved hash function for pointers.
IPageAccessControlSvc
Interface to a service that monitors memory page accesses.
Definition: IPageAccessControlSvc.h:30
SG::T2pMap::m_t2p
t2p m_t2p
Definition: T2pMap.h:72
lumiFormat.i
int i
Definition: lumiFormat.py:92
SG::T2pMap::m_mutex
std::mutex m_mutex
Definition: T2pMap.h:73
DataProxy
DataProxy provides the registry services for StoreGate.
Definition: DataProxy.h:31
SG::T2pMap::t2pRegister
bool t2pRegister(const void *const pTrans, DataProxy *const pPers)
Definition: T2pMap.h:34
SG::T2pMap::clear
void clear()
Definition: T2pMap.h:53
IPageAccessControlSvc::controlPage
virtual bool controlPage(const void *address)=0
control access to the page containing address
SG::T2pMap::m_pac
IPageAccessControlSvc * m_pac
Definition: T2pMap.h:71
SG::T2pMap::t2pRemove
void t2pRemove(const void *const pTrans)
Definition: T2pMap.h:59
SG::T2pMap::pacReport
std::vector< const DataProxy * > pacReport() const
request an access control report, i.e. a list of proxies that have not been accessed since under cont...
Definition: T2pMap.cxx:7
SG::DataProxy
Definition: DataProxy.h:44
SG::T2pMap
Definition: T2pMap.h:21