FWCore
Framework
interface
DataProxyTemplate.h
Go to the documentation of this file.
1
#ifndef FWCore_Framework_DataProxyTemplate_h
2
#define FWCore_Framework_DataProxyTemplate_h
3
// -*- C++ -*-
4
//
5
// Package: Framework
6
// Class : DataProxyTemplate
7
//
26
//
27
// Author: Chris Jones
28
// Created: Thu Mar 31 12:45:32 EST 2005
29
//
30
31
// system include files
32
33
// user include files
34
#include "
FWCore/Framework/interface/DataProxy.h
"
35
#include "
FWCore/Framework/interface/EventSetupRecord.h
"
36
#include "
FWCore/ServiceRegistry/interface/ServiceRegistry.h
"
37
#include "
FWCore/Concurrency/interface/WaitingTaskList.h
"
38
#include <cassert>
39
#include <limits>
40
#include <atomic>
41
42
// forward declarations
43
44
namespace
edm
{
45
46
class
EventSetupImpl;
47
48
namespace
eventsetup {
49
50
template
<
class
RecordT,
class
DataT>
51
class
DataProxyTemplate
:
public
DataProxy
{
52
public
:
53
typedef
DataT
value_type
;
54
typedef
RecordT
record_type
;
55
56
DataProxyTemplate
() {}
57
58
void
prefetchAsyncImpl
(
WaitingTask
* iTask,
59
const
EventSetupRecordImpl
& iRecord,
60
const
DataKey
& iKey,
61
EventSetupImpl
const
* iEventSetupImpl,
62
edm::ServiceToken
const
& iToken)
override
{
63
assert
(iRecord.
key
() == RecordT::keyForClass());
64
bool
expected =
false
;
65
bool
doPrefetch =
prefetching_
.compare_exchange_strong(expected,
true
);
66
taskList_
.
add
(iTask);
67
68
if
(doPrefetch) {
69
tbb::task::spawn(*
edm::make_waiting_task
(
70
tbb::task::allocate_root(), [
this
, &iRecord, iKey, iEventSetupImpl, iToken](std::exception_ptr
const
*) {
71
try
{
72
RecordT rec;
73
rec.setImpl(&iRecord,
std::numeric_limits<unsigned int>::max
(),
nullptr
, iEventSetupImpl,
true
);
74
ServiceRegistry::Operate
operate(iToken);
75
this->
make
(rec, iKey);
76
}
catch
(...) {
77
this->
taskList_
.
doneWaiting
(std::current_exception());
78
return
;
79
}
80
this->
taskList_
.
doneWaiting
(std::exception_ptr{});
81
}));
82
}
83
}
84
85
protected
:
86
void
invalidateCache
()
override
{
87
taskList_
.
reset
();
88
prefetching_
=
false
;
89
}
90
91
virtual
const
DataT*
make
(
const
RecordT&,
const
DataKey
&) = 0;
92
93
private
:
94
WaitingTaskList
taskList_
;
95
std::atomic<bool>
prefetching_
{
false
};
96
};
97
98
}
// namespace eventsetup
99
}
// namespace edm
100
#endif
edm::eventsetup::DataProxyTemplate::record_type
RecordT record_type
Definition:
DataProxyTemplate.h:54
ServiceRegistry.h
edm::eventsetup::DataProxyTemplate::prefetching_
std::atomic< bool > prefetching_
Definition:
DataProxyTemplate.h:95
edm::eventsetup::DataProxyTemplate::value_type
DataT value_type
Definition:
DataProxyTemplate.h:53
edm::EventSetupImpl
Definition:
EventSetupImpl.h:48
edm
HLT enums.
Definition:
AlignableModifier.h:19
edm::WaitingTaskList::add
void add(WaitingTask *)
Adds task to the waiting list.
Definition:
WaitingTaskList.cc:90
cms::cuda::assert
assert(be >=bs)
edm::eventsetup::DataKey
Definition:
DataKey.h:29
DataProxy.h
EventSetupRecord.h
edm::WaitingTaskList::reset
void reset()
Resets access to the resource so that added tasks will wait.
Definition:
WaitingTaskList.cc:52
edm::WaitingTaskList
Definition:
WaitingTaskList.h:101
edm::eventsetup::DataProxyTemplate::invalidateCache
void invalidateCache() override
Definition:
DataProxyTemplate.h:86
edm::ServiceToken
Definition:
ServiceToken.h:40
edm::eventsetup::DataProxyTemplate::DataProxyTemplate
DataProxyTemplate()
Definition:
DataProxyTemplate.h:56
edm::WaitingTaskList::doneWaiting
void doneWaiting(std::exception_ptr iPtr)
Signals that the resource is now available and tasks should be spawned.
Definition:
WaitingTaskList.cc:170
edm::make_waiting_task
FunctorWaitingTask< F > * make_waiting_task(ALLOC &&iAlloc, F f)
Definition:
WaitingTask.h:87
edm::eventsetup::EventSetupRecordImpl
Definition:
EventSetupRecordImpl.h:76
edm::eventsetup::DataProxyTemplate::taskList_
WaitingTaskList taskList_
Definition:
DataProxyTemplate.h:94
edm::eventsetup::EventSetupRecordImpl::key
EventSetupRecordKey const & key() const
Definition:
EventSetupRecordImpl.h:102
SiStripPI::max
Definition:
SiStripPayloadInspectorHelper.h:169
edm::eventsetup::DataProxyTemplate::prefetchAsyncImpl
void prefetchAsyncImpl(WaitingTask *iTask, const EventSetupRecordImpl &iRecord, const DataKey &iKey, EventSetupImpl const *iEventSetupImpl, edm::ServiceToken const &iToken) override
Definition:
DataProxyTemplate.h:58
edm::eventsetup::DataProxy
Definition:
DataProxy.h:41
edm::eventsetup::DataProxyTemplate::make
virtual const DataT * make(const RecordT &, const DataKey &)=0
edm::WaitingTask
Definition:
WaitingTask.h:36
WaitingTaskList.h
edm::eventsetup::DataProxyTemplate
Definition:
DataProxyTemplate.h:51
edm::ServiceRegistry::Operate
Definition:
ServiceRegistry.h:40
Generated for CMSSW Reference Manual by
1.8.16