Skip to content

Commit

Permalink
terminate when distructed before stopped
Browse files Browse the repository at this point in the history
  • Loading branch information
floriantschopp committed Mar 22, 2024
1 parent bd3be14 commit c26d98e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions modules/concurrency/src/spinner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "hephaestus/concurrency/spinner.h"

#include <absl/log/log.h>
#include <fmt/format.h>

#include "hephaestus/base/exception.h"
Expand All @@ -13,12 +14,9 @@ Spinner::Spinner() : is_started_(false) {
}

Spinner::~Spinner() {
try {
if (is_started_.load() && spinner_thread_.joinable()) {
stop();
}
} catch (const std::exception& ex) {
fmt::print("Error stopping spinner: {}", ex.what());
if (is_started_.load() || spinner_thread_.joinable()) {
LOG(FATAL) << "Spinner is still running. Call stop() before destroying the object.";
std::terminate();
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/utils/src/version_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ static constexpr std::uint16_t VERSION_PATCH = 1;

static constexpr std::string_view REPO_BRANCH = "feature/spinner";
static constexpr std::string_view BUILD_PROFILE = "RelWithDebInfo";
static constexpr std::string_view REPO_HASH = "955d99b";
static constexpr std::string_view REPO_HASH = "bd3be14";

} // namespace heph::utils

0 comments on commit c26d98e

Please sign in to comment.