ATLAS Offline Software
Loading...
Searching...
No Matches
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
17namespace SG {
18
19class DataProxy;
20
21class T2pMap {
22
23 public:
24
25 typedef std::unordered_map<const void*, DataProxy*, ptrhash> t2p;
26
27 // constructor
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
67 std::vector<const DataProxy*> pacReport() const;
68
69
70 private:
73 mutable std::mutex m_mutex;
74};
75
76}
77#endif
Interface to a service that monitors memory page accesses.
std::unordered_map< const void *, DataProxy *, ptrhash > t2p
Definition T2pMap.h:25
t2p m_t2p
Definition T2pMap.h:72
~T2pMap()
Definition T2pMap.h:31
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
void setPac(IPageAccessControlSvc *pac)
set IPageAccessControlSvc ptr in T2PMap
Definition T2pMap.h:65
DataProxy * locatePersistent(const void *const pTransient) const
Definition T2pMap.h:42
void clear()
Definition T2pMap.h:53
bool t2pRegister(const void *const pTrans, DataProxy *const pPers)
Definition T2pMap.h:34
void t2pRemove(const void *const pTrans)
Definition T2pMap.h:59
T2pMap(IPageAccessControlSvc *pac=0)
Definition T2pMap.h:28
std::mutex m_mutex
Definition T2pMap.h:73
IPageAccessControlSvc * m_pac
Definition T2pMap.h:71
Forward declaration.
Improved hash function for pointers.