Skip to content

Commit

Permalink
Fix clang-tidy warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
lhruby committed Oct 22, 2024
1 parent edd3ad5 commit 5f052b3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions modules/concurrency/include/hephaestus/concurrency/spinner.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ namespace heph::concurrency {
/// the given fixed rate.
class Spinner {
public:
enum class SpinResult : bool { Continue, Stop };
enum class SpinResult : bool { CONTINUE, STOP };
using StoppableCallback = std::function<SpinResult()>;
using Callback = std::function<void()>;

/// @brief Create a spinner with a stoppable callback. A stoppable callback is a function that returns
/// SpinResult::Stop to indicate that the spinner should stop.
/// SpinResult::STOP to indicate that the spinner should stop.
/// Example: a callback that stops after 10 iterations.
explicit Spinner(StoppableCallback&& stoppable_callback, double rate_hz = 0);

Expand Down
5 changes: 2 additions & 3 deletions modules/concurrency/src/spinner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <functional>
#include <future>
#include <mutex>
#include <thread>
#include <utility>

#include <absl/log/log.h>
Expand Down Expand Up @@ -40,7 +39,7 @@ Spinner::Spinner(StoppableCallback&& stoppable_callback, double rate_hz /*= 0*/)
Spinner::Spinner(Callback&& callback, double rate_hz /*= 0*/)
: Spinner(StoppableCallback([cb = std::move(callback)]() -> SpinResult {
cb();
return SpinResult::Continue;
return SpinResult::CONTINUE;
}),
rate_hz) {
}
Expand Down Expand Up @@ -68,7 +67,7 @@ void Spinner::spin() {

++spin_count_;

if (spin_result == SpinResult::Stop) {
if (spin_result == SpinResult::STOP) {
break;
}

Expand Down
5 changes: 2 additions & 3 deletions modules/concurrency/tests/spinner_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include <chrono>
#include <cstddef>
#include <functional>
#include <thread>

#include <gtest/gtest.h>
Expand All @@ -24,10 +23,10 @@ struct TestFixture : public ::testing::Test {
static constexpr auto STOP_AFTER = 10;
if (callback_called_counter < STOP_AFTER) {
++callback_called_counter;
return Spinner::SpinResult::Continue;
return Spinner::SpinResult::CONTINUE;
}

return Spinner::SpinResult::Stop;
return Spinner::SpinResult::STOP;
};
}

Expand Down

0 comments on commit 5f052b3

Please sign in to comment.