diff --git a/libs/core/errors/include/hpx/errors/exception_list.hpp b/libs/core/errors/include/hpx/errors/exception_list.hpp index fd115db38db..df259287a75 100644 --- a/libs/core/errors/include/hpx/errors/exception_list.hpp +++ b/libs/core/errors/include/hpx/errors/exception_list.hpp @@ -45,7 +45,10 @@ namespace hpx { exception_list_type exceptions_; mutable mutex_type mtx_; - void add_no_lock(std::exception_ptr const& e); + void add_no_lock(std::exception_ptr const& e) + { + exceptions_.push_back(e); + } /// \endcond public: @@ -56,18 +59,56 @@ namespace hpx { // \throws nothing ~exception_list() noexcept override = default; - exception_list(); - explicit exception_list(std::exception_ptr const& e); - explicit exception_list(exception_list_type&& l); + exception_list() = default; - exception_list(exception_list const& l); - exception_list(exception_list&& l) noexcept; + explicit exception_list(std::exception_ptr const& e) + { + add(e); + } - exception_list& operator=(exception_list const& l); - exception_list& operator=(exception_list&& l) noexcept; + explicit exception_list(exception_list_type&& l) + { + std::lock_guard lock(mtx_); + exceptions_ = std::move(l); + } - /// - void add(std::exception_ptr const& e); + exception_list(exception_list const& l) : hpx::exception(l) + { + std::lock_guard lock(l.mtx_); + exceptions_ = l.exceptions_; + } + + exception_list(exception_list&& l) noexcept : hpx::exception(std::move(l)) + { + std::lock_guard l_lock(l.mtx_); + exceptions_ = std::move(l.exceptions_); + } + + exception_list& operator=(exception_list const& l) + { + if (this != &l) { + std::lock_guard this_lock(mtx_); + std::lock_guard l_lock(l.mtx_); + exceptions_ = l.exceptions_; + } + return *this; + } + + exception_list& operator=(exception_list&& l) noexcept + { + if (this != &l) { + std::lock_guard this_lock(mtx_); + std::lock_guard l_lock(l.mtx_); + exceptions_ = std::move(l.exceptions_); + } + return *this; + } + + void add(std::exception_ptr const& e) + { + std::lock_guard l(mtx_); + add_no_lock(e); + } /// \endcond /// The number of exception_ptr objects contained within the @@ -96,9 +137,15 @@ namespace hpx { } /// \cond NOINTERNAL - [[nodiscard]] std::error_code get_error_code() const; + [[nodiscard]] std::error_code get_error_code() const + { + return std::error_code(); // placeholder implementation + } - [[nodiscard]] std::string get_message() const; + [[nodiscard]] std::string get_message() const + { + return "Exception occurred"; // placeholder implementation + } /// \endcond }; } // namespace hpx