Skip to content

Commit 8cf2f53

Browse files
committed
DPL: add ability to get the toplevel service registry
This will allows non DPL code to still exploit some of the DPL services, like monitoring.
1 parent cbace39 commit 8cf2f53

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

Framework/Core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ o2_add_library(Framework
125125
src/RootArrowFilesystem.cxx
126126
src/SendingPolicy.cxx
127127
src/ServiceRegistry.cxx
128+
src/ServiceRegistryRef.cxx
128129
src/ServiceSpec.cxx
129130
src/SimpleResourceManager.cxx
130131
src/SimpleRawDeviceService.cxx

Framework/Core/include/Framework/ServiceRegistryRef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ class ServiceRegistryRef
112112
mRegistry.unlock(mSalt);
113113
}
114114

115+
static ServiceRegistryRef *globalDeviceRef(ServiceRegistryRef *ref = nullptr);
116+
115117
private:
116118
ServiceRegistry& mRegistry;
117119
ServiceRegistry::Salt mSalt;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2019-2026 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
13+
#include "Framework/ServiceRegistryRef.h"
14+
namespace o2::framework {
15+
16+
ServiceRegistryRef *ServiceRegistryRef::globalDeviceRef(ServiceRegistryRef *ref) {
17+
static ServiceRegistryRef *globalRef = nullptr;
18+
if (!globalRef) {
19+
globalRef = ref;
20+
}
21+
// We return a copy, so that it can be cache
22+
return globalRef;
23+
}
24+
25+
}

Framework/Core/src/runDataProcessing.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,6 +1429,7 @@ int runStateMachine(DataProcessorSpecs const& workflow,
14291429
// We initialise this in the driver, because different drivers might have
14301430
// different versions of the service
14311431
ServiceRegistry serviceRegistry;
1432+
ServiceRegistryRef::globalDeviceRef(new ServiceRegistryRef{serviceRegistry, ServiceRegistry::globalDeviceSalt()});
14321433

14331434
if ((driverConfig.batch == false || getenv("DPL_DRIVER_REMOTE_GUI") != nullptr) && frameworkId.empty()) {
14341435
debugGUI = initDebugGUI();

0 commit comments

Comments
 (0)