From f6498019a093b07ddc894ee5f2467ae158bcb21c Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Thu, 2 Jan 2025 18:29:15 +0100 Subject: [PATCH] DPL: drop unneeded ScopedExit helper --- Framework/Core/src/DataProcessingDevice.cxx | 2 - Framework/Core/src/ScopedExit.h | 148 -------------------- 2 files changed, 150 deletions(-) delete mode 100644 Framework/Core/src/ScopedExit.h diff --git a/Framework/Core/src/DataProcessingDevice.cxx b/Framework/Core/src/DataProcessingDevice.cxx index da92c73e1e16a..8a3fbbcf5b2f1 100644 --- a/Framework/Core/src/DataProcessingDevice.cxx +++ b/Framework/Core/src/DataProcessingDevice.cxx @@ -52,8 +52,6 @@ #include "Headers/DataHeader.h" #include "Headers/DataHeaderHelpers.h" -#include "ScopedExit.h" - #include #include diff --git a/Framework/Core/src/ScopedExit.h b/Framework/Core/src/ScopedExit.h deleted file mode 100644 index aca3c1a19d8b1..0000000000000 --- a/Framework/Core/src/ScopedExit.h +++ /dev/null @@ -1,148 +0,0 @@ -// 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 -#include - -namespace o2::framework -{ -namespace detail -{ -// Original from https://github.com/ricab/scope_guard -// which is licensed to public domain -// Type trait determining whether a type is callable with no arguments -template -struct is_noarg_callable_t - : public std::false_type { -}; // in general, false - -template -struct is_noarg_callable_t()())> - : public std::true_type { -}; // only true when call expression valid - -// Type trait determining whether a no-argument callable returns void -template -struct returns_void_t - : public std::is_same()())> { -}; - -/* Type trait determining whether a no-arg callable is nothrow invocable if - required. This is where SG_REQUIRE_NOEXCEPT logic is encapsulated. */ -template -struct is_nothrow_invocable_if_required_t - : public std::is_nothrow_invocable /* Note: _r variants not enough to - confirm void return: any return can be - discarded so all returns are - compatible with void */ -{ -}; - -template -struct and_t : public and_t> { -}; - -template -struct and_t : public std::conditional::type { -}; - -template -struct is_proper_sg_callback_t - : public and_t, - returns_void_t, - is_nothrow_invocable_if_required_t, - std::is_nothrow_destructible> { -}; - -template ::value>::type> -class scope_guard; - -template -detail::scope_guard make_scope_guard(Callback&& callback) noexcept(std::is_nothrow_constructible::value); - -template -class scope_guard final -{ - public: - typedef Callback callback_type; - - scope_guard(scope_guard&& other) noexcept(std::is_nothrow_constructible::value); - - ~scope_guard() noexcept; // highlight noexcept dtor - - void dismiss() noexcept; - - public: - scope_guard() = delete; - scope_guard(const scope_guard&) = delete; - scope_guard& operator=(const scope_guard&) = delete; - scope_guard& operator=(scope_guard&&) = delete; - - private: - explicit scope_guard(Callback&& callback) noexcept(std::is_nothrow_constructible::value); /* - meant for friends only */ - - friend scope_guard make_scope_guard(Callback&&) noexcept(std::is_nothrow_constructible::value); /* - only make_scope_guard can create scope_guards from scratch (i.e. non-move) - */ - - private: - Callback mCallback; - bool mActive; -}; - -} // namespace detail - -using detail::make_scope_guard; // see comment on declaration above - -template -detail::scope_guard::scope_guard(Callback&& callback) noexcept(std::is_nothrow_constructible::value) - : mCallback(std::forward(callback)) /* use () instead of {} because - of DR 1467 (https://is.gd/WHmWuo), which still impacts older compilers - (e.g. GCC 4.x and clang <=3.6, see https://godbolt.org/g/TE9tPJ and - https://is.gd/Tsmh8G) */ - , - mActive{true} -{ -} - -template -detail::scope_guard::~scope_guard() noexcept -{ - if (mActive) { - mCallback(); - } -} - -template -detail::scope_guard::scope_guard(scope_guard&& other) noexcept(std::is_nothrow_constructible::value) - : mCallback(std::forward(other.mCallback)) // idem - , - mActive{std::move(other.mActive)} -{ - other.mActive = false; -} - -template -inline void detail::scope_guard::dismiss() noexcept -{ - mActive = false; -} - -template -inline auto detail::make_scope_guard(Callback&& callback) noexcept(std::is_nothrow_constructible::value) - -> detail::scope_guard -{ - return detail::scope_guard{std::forward(callback)}; -} - -} // namespace o2::framework