Skip to content

Commit 72d6079

Browse files
committed
DPL: ServiceRegistry now needs a salt to get services
1 parent 26c06cb commit 72d6079

5 files changed

Lines changed: 112 additions & 85 deletions

File tree

Framework/Core/include/Framework/ServiceRegistry.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,24 +331,24 @@ struct ServiceRegistry {
331331

332332
/// Check if service of type T is currently active.
333333
template <typename T>
334-
std::enable_if_t<std::is_const_v<T> == false, bool> active() const
334+
std::enable_if_t<std::is_const_v<T> == false, bool> active(Salt salt) const
335335
{
336336
constexpr ServiceTypeHash typeHash{TypeIdHelpers::uniqueId<T>()};
337337
if (this->getPos(typeHash, GLOBAL_CONTEXT_SALT) != -1) {
338338
return true;
339339
}
340-
auto result = this->getPos(typeHash, ServiceRegistry::threadSalt()) != -1;
340+
auto result = this->getPos(typeHash, salt) != -1;
341341
return result;
342342
}
343343

344344
/// Get a service for the given interface T. The returned reference exposed to
345345
/// the user is actually of the last concrete type C registered, however this
346346
/// should not be a problem.
347347
template <typename T>
348-
T& get() const
348+
T& get(Salt salt) const
349349
{
350350
constexpr ServiceTypeHash typeHash{TypeIdHelpers::uniqueId<T>()};
351-
auto ptr = this->get(typeHash, ServiceRegistry::threadSalt(), ServiceKind::Serial, typeid(T).name());
351+
auto ptr = this->get(typeHash, salt, ServiceKind::Serial, typeid(T).name());
352352
if (O2_BUILTIN_LIKELY(ptr != nullptr)) {
353353
if constexpr (std::is_const_v<T>) {
354354
return *reinterpret_cast<T const*>(ptr);

Framework/Core/include/Framework/ServiceRegistryRef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ServiceRegistryRef
4545
template <typename T>
4646
std::enable_if_t<std::is_const_v<T> == false, bool> active() const
4747
{
48-
return mRegistry.active<T>();
48+
return mRegistry.active<T>(ServiceRegistry::threadSalt());
4949
}
5050

5151
/// Get a service for the given interface T. The returned reference exposed to
@@ -54,7 +54,7 @@ class ServiceRegistryRef
5454
template <typename T>
5555
T& get() const
5656
{
57-
return mRegistry.get<T>();
57+
return mRegistry.get<T>(ServiceRegistry::threadSalt());
5858
}
5959

6060
/// Invoke before sending messages @a parts on a channel @a channelindex

0 commit comments

Comments
 (0)