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

Update exception_list.hpp #6568

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
71 changes: 59 additions & 12 deletions libs/core/errors/include/hpx/errors/exception_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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<mutex_type> 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<mutex_type> lock(l.mtx_);
exceptions_ = l.exceptions_;
}

exception_list(exception_list&& l) noexcept : hpx::exception(std::move(l))
{
std::lock_guard<mutex_type> l_lock(l.mtx_);
exceptions_ = std::move(l.exceptions_);
}

exception_list& operator=(exception_list const& l)
{
if (this != &l) {
std::lock_guard<mutex_type> this_lock(mtx_);
std::lock_guard<mutex_type> l_lock(l.mtx_);
exceptions_ = l.exceptions_;
}
return *this;
}

exception_list& operator=(exception_list&& l) noexcept
{
if (this != &l) {
std::lock_guard<mutex_type> this_lock(mtx_);
std::lock_guard<mutex_type> l_lock(l.mtx_);
exceptions_ = std::move(l.exceptions_);
}
return *this;
}

void add(std::exception_ptr const& e)
{
std::lock_guard<mutex_type> l(mtx_);
add_no_lock(e);
}
/// \endcond

/// The number of exception_ptr objects contained within the
Expand Down Expand Up @@ -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
Expand Down
Loading