Skip to content

Commit 5c45332

Browse files
committed
DPL: improve services to support multiple DP running on the same device
1 parent 3d9a111 commit 5c45332

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

Framework/Core/include/Framework/ServiceHandle.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,17 @@ namespace o2::framework
1919
/// The kind of service we are asking for
2020
enum struct ServiceKind {
2121
/// A Service which is not thread safe, therefore all accesses to it must be mutexed.
22-
Serial,
22+
DeviceSerial,
2323
/// A Service which is thread safe and therefore can be used by many threads the same time without risk
24-
Global,
24+
DeviceGlobal,
2525
/// A Service which is specific to a given thread in a thread pool
26-
Stream
26+
DeviceStream,
27+
DataProcessorSerial,
28+
DataProcessorGlobal,
29+
DataProcessorStream,
30+
Serial = DataProcessorSerial,
31+
Global = DataProcessorGlobal,
32+
Stream = DataProcessorStream
2733
};
2834

2935
struct ServiceTypeHash {

Framework/Core/src/ServiceRegistry.cxx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,18 @@ void* ServiceRegistry::get(ServiceTypeHash typeHash, Salt salt, ServiceKind kind
289289
O2_BUILTIN_UNREACHABLE();
290290
}
291291

292-
if (pos != -1 && mServicesMeta[pos].kind == ServiceKind::Stream && salt.context.streamId <= 0) {
292+
bool isStream = mServicesMeta[pos].kind == ServiceKind::DataProcessorStream || mServicesMeta[pos].kind == ServiceKind::DeviceStream;
293+
bool isDataProcessor = mServicesMeta[pos].kind == ServiceKind::DataProcessorStream || mServicesMeta[pos].kind == ServiceKind::DataProcessorGlobal || mServicesMeta[pos].kind == ServiceKind::DataProcessorSerial;
294+
295+
if (pos != -1 && isStream && salt.context.streamId <= 0) {
293296
throwError(runtime_error_f("A stream service cannot be retrieved from a non stream salt %d", salt.context.streamId));
294297
O2_BUILTIN_UNREACHABLE();
295298
}
299+
300+
if (pos != -1 && isDataProcessor && salt.context.dataProcessorId < 0) {
301+
throwError(runtime_error_f("A data processor service cannot be retrieved from a non dataprocessor context %d", salt.context.dataProcessorId));
302+
O2_BUILTIN_UNREACHABLE();
303+
}
296304

297305
if (pos != -1) {
298306
mServicesKey[pos].load();

0 commit comments

Comments
 (0)