Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DPL: Drop generic code to chose between unique and shared pointers #13526

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Framework/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ add_executable(o2-test-framework-core
test/test_OptionsHelpers.cxx
test/test_OverrideLabels.cxx
test/test_O2DataModelHelpers.cxx
test/test_PtrHelpers.cxx
test/test_RootConfigParamHelpers.cxx
test/test_Services.cxx
test/test_StringHelpers.cxx
Expand Down
27 changes: 0 additions & 27 deletions Framework/Core/include/Framework/TypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,32 +164,5 @@ struct has_root_setowner<
void>> : public std::true_type {
};

/// Helper class to deal with the case we are creating the first instance of a
/// (possibly) shared resource.
///
/// works for both:
///
/// std::shared_ptr<Base> storage = make_matching<decltype(storage), Concrete1>(args...);
///
/// or
///
/// std::unique_ptr<Base> storage = make_matching<decltype(storage), Concrete1>(args...);
///
/// Useful to deal with those who cannot make up their mind about ownership.
/// ;-)
template <typename HOLDER, typename T, typename... ARGS>
static std::enable_if_t<sizeof(std::declval<HOLDER>().unique()) != 0, HOLDER>
make_matching(ARGS&&... args)
{
return std::make_shared<T>(std::forward<ARGS>(args)...);
}

template <typename HOLDER, typename T, typename... ARGS>
static std::enable_if_t<sizeof(std::declval<HOLDER>().get_deleter()) != 0, HOLDER>
make_matching(ARGS&&... args)
{
return std::make_unique<T>(std::forward<ARGS>(args)...);
}

} // namespace o2::framework
#endif // FRAMEWORK_TYPETRAITS_H
5 changes: 1 addition & 4 deletions Framework/Core/src/runDataProcessing.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1098,10 +1098,7 @@ int doChild(int argc, char** argv, ServiceRegistry& serviceRegistry,
serviceRef.registerService(ServiceRegistryHelpers::handleForService<DeviceContext>(deviceContext.get()));
serviceRef.registerService(ServiceRegistryHelpers::handleForService<DriverConfig const>(&driverConfig));

// The decltype stuff is to be able to compile with both new and old
// FairMQ API (one which uses a shared_ptr, the other one a unique_ptr.
decltype(r.fDevice) device;
device = make_matching<decltype(device), DataProcessingDevice>(ref, serviceRegistry, processingPolicies);
auto device = std::make_unique<DataProcessingDevice>(ref, serviceRegistry, processingPolicies);

serviceRef.get<RawDeviceService>().setDevice(device.get());
r.fDevice = std::move(device);
Expand Down
45 changes: 0 additions & 45 deletions Framework/Core/test/test_PtrHelpers.cxx

This file was deleted.

Loading