-
Notifications
You must be signed in to change notification settings - Fork 499
Expand file tree
/
Copy pathDataProcessingContext.cxx
More file actions
157 lines (137 loc) · 7.38 KB
/
DataProcessingContext.cxx
File metadata and controls
157 lines (137 loc) · 7.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include "Framework/DataProcessingContext.h"
#include "Framework/DataProcessorSpec.h"
#include "Framework/EndOfStreamContext.h"
#include "Framework/TimingInfo.h"
#include "Framework/Signpost.h"
O2_DECLARE_DYNAMIC_LOG(data_processor_context);
O2_DECLARE_DYNAMIC_LOG(calibration);
namespace o2::framework
{
namespace
{
template <typename T, typename... ARGS>
void invokeAll(T& handles, char const* callbackName, o2::framework::DataProcessorSpec* spec, ARGS&... args)
{
assert(callbackName);
O2_SIGNPOST_ID_FROM_POINTER(dpid, data_processor_context, spec);
// FIXME: for now spec is nullptr because we don't have a list of possible DataProcessorSpecs
// per device.
char const* dataProcessorName = spec ? spec->name.c_str() : "DataProcessorContext";
O2_SIGNPOST_START(data_processor_context, dpid, "callbacks", "Starting %{public}s::%{public}s", dataProcessorName, callbackName);
for (auto& handle : handles) {
O2_SIGNPOST_ID_FROM_POINTER(cid, data_processor_context, handle.service);
O2_SIGNPOST_START(data_processor_context, cid, "callbacks", "Starting %{public}s::%{public}s::%{public}s", dataProcessorName, handle.spec.name.c_str(), callbackName);
handle.callback(args..., handle.service);
O2_SIGNPOST_END(data_processor_context, cid, "callbacks", "Ending %{public}s::%{public}s::%{public}s", dataProcessorName, handle.spec.name.c_str(), callbackName);
}
O2_SIGNPOST_END(data_processor_context, dpid, "callbacks", "Ending %{public}s::%{public}s", dataProcessorName, callbackName);
}
} // namespace
/// Invoke callbacks to be executed before every dangling check
void DataProcessorContext::preProcessingCallbacks(ProcessingContext& ctx)
{
invokeAll(preProcessingHandlers, "preProcessingCallbacks", spec, ctx);
}
void DataProcessorContext::finaliseOutputsCallbacks(ProcessingContext& ctx)
{
invokeAll(finaliseOutputsHandles, "finaliseOutputsCallbacks", spec, ctx);
}
/// Invoke callbacks to be executed before every dangling check
void DataProcessorContext::postProcessingCallbacks(ProcessingContext& ctx)
{
invokeAll(postProcessingHandlers, "postProcessingCallbacks", spec, ctx);
}
/// Invoke callbacks to be executed before every dangling check
void DataProcessorContext::preDanglingCallbacks(DanglingContext& ctx)
{
invokeAll(preDanglingHandles, "preDanglingCallbacks", spec, ctx);
}
/// Invoke callbacks to be executed after every dangling check
void DataProcessorContext::postDanglingCallbacks(DanglingContext& ctx)
{
invokeAll(postDanglingHandles, "postDanglingCallbacks", spec, ctx);
}
/// Invoke callbacks to be executed before every EOS user callback invokation
void DataProcessorContext::preEOSCallbacks(EndOfStreamContext& ctx)
{
invokeAll(preEOSHandles, "preEOSCallbacks", spec, ctx);
}
/// Invoke callbacks to be executed after every EOS user callback invokation
void DataProcessorContext::postEOSCallbacks(EndOfStreamContext& ctx)
{
invokeAll(postEOSHandles, "postEOSCallbacks", spec, ctx);
}
/// Invoke callbacks to be executed after every data Dispatching
void DataProcessorContext::postDispatchingCallbacks(ProcessingContext& ctx)
{
invokeAll(postDispatchingHandles, "postDispatchingCallbacks", spec, ctx);
}
/// Invoke callbacks to be executed after every data Dispatching
void DataProcessorContext::postForwardingCallbacks(ProcessingContext& ctx)
{
invokeAll(postForwardingHandles, "postForwardingCallbacks", spec, ctx);
}
/// Callbacks to be called in fair::mq::Device::PreRun()
void DataProcessorContext::preStartCallbacks(ServiceRegistryRef ref)
{
invokeAll(preStartHandles, "preStartCallbacks", spec, ref);
}
void DataProcessorContext::postStopCallbacks(ServiceRegistryRef ref)
{
invokeAll(postStopHandles, "postStopCallbacks", spec, ref);
}
/// Invoke callback to be executed on exit, in reverse order.
void DataProcessorContext::preExitCallbacks(std::vector<ServiceExitHandle> handles, ServiceRegistryRef ref)
{
O2_SIGNPOST_ID_FROM_POINTER(dpid, data_processor_context, &ref);
O2_SIGNPOST_START(data_processor_context, dpid, "callbacks", "Starting DataProcessorContext preExitCallbacks");
// FIXME: we need to call the callback only once for the global services
/// I guess...
for (auto handle = handles.rbegin(); handle != handles.rend(); ++handle) {
O2_SIGNPOST_ID_FROM_POINTER(cid, data_processor_context, handle->service);
O2_SIGNPOST_START(data_processor_context, cid, "callbacks", "Starting DataProcessorContext::preExitCallbacks for service %{public}s", handle->spec.name.c_str());
handle->callback(ref, handle->service);
O2_SIGNPOST_END(data_processor_context, cid, "callbacks", "Ending DataProcessorContext::preExitCallbacks for service %{public}s", handle->spec.name.c_str());
}
O2_SIGNPOST_END(data_processor_context, dpid, "callbacks", "Ending DataProcessorContext preExitCallbacks");
}
/// Invoke callback to be executed on exit, in reverse order.
void DataProcessorContext::preLoopCallbacks(ServiceRegistryRef ref)
{
invokeAll(preLoopHandles, "preLoopCallbacks", spec, ref);
}
void DataProcessorContext::domainInfoUpdatedCallback(ServiceRegistryRef ref, size_t oldestPossibleTimeslice, ChannelIndex channelIndex)
{
O2_SIGNPOST_ID_FROM_POINTER(dpid, data_processor_context, this);
O2_SIGNPOST_START(data_processor_context, dpid, "callbacks", "Starting DataProcessorContext domainInfoUpdatedCallback");
for (auto& handle : domainInfoHandles) {
O2_SIGNPOST_ID_FROM_POINTER(cid, data_processor_context, handle.service);
O2_SIGNPOST_START(data_processor_context, cid, "callbacks", "Starting DataProcessorContext::domainInfoUpdatedCallback for service %{public}s", handle.spec.name.c_str());
handle.callback(ref, oldestPossibleTimeslice, channelIndex);
O2_SIGNPOST_END(data_processor_context, cid, "callbacks", "Ending DataProcessorContext::domainInfoUpdatedCallback for service %{public}s", handle.spec.name.c_str());
}
O2_SIGNPOST_END(data_processor_context, dpid, "callbacks", "Ending DataProcessorContext domainInfoUpdatedCallback");
}
void DataProcessorContext::preSendingMessagesCallbacks(ServiceRegistryRef ref, fair::mq::Parts& parts, ChannelIndex channelIndex)
{
O2_SIGNPOST_ID_FROM_POINTER(dpid, data_processor_context, this);
O2_SIGNPOST_START(data_processor_context, dpid, "callbacks", "Starting DataProcessorContext preSendingMessagesCallbacks");
for (auto& handle : preSendingMessagesHandles) {
O2_SIGNPOST_ID_FROM_POINTER(cid, data_processor_context, handle.service);
O2_SIGNPOST_START(data_processor_context, cid, "callbacks", "Starting DataProcessorContext::preSendingMessagesCallbacks for service %{public}s", handle.spec.name.c_str());
handle.callback(ref, parts, channelIndex);
O2_SIGNPOST_END(data_processor_context, cid, "callbacks", "Ending DataProcessorContext::preSendingMessagesCallbacks for service %{public}s", handle.spec.name.c_str());
}
O2_SIGNPOST_END(data_processor_context, dpid, "callbacks", "Ending DataProcessorContext preSendingMessagesCallbacks");
}
} // namespace o2::framework