Skip to content

Commit

Permalink
infra: fix Clang Tidy warnings after PR 1787
Browse files Browse the repository at this point in the history
  • Loading branch information
canepat committed Feb 9, 2024
1 parent 782b019 commit 10207dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions silkworm/infra/common/bounded_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@

namespace silkworm {

template <class T>
/**
* @class bounded_buffer
* @class BoundedBuffer
* @brief A thread-safe bounded buffer implementation.
*
* The bounded_buffer class provides a fixed-size buffer that can be accessed by multiple threads concurrently.
Expand All @@ -36,13 +35,17 @@ template <class T>
*
* @tparam T The type of items stored in the buffer.
*/
template <class T>
class BoundedBuffer {
public:
using size_type = typename boost::circular_buffer<T>::size_type;
using value_type = typename boost::circular_buffer<T>::value_type;

explicit BoundedBuffer(size_type capacity) : capacity_{capacity}, unread_(0), container_(capacity) {}

BoundedBuffer(const BoundedBuffer&) = delete; // Disabled copy constructor
BoundedBuffer& operator=(const BoundedBuffer&) = delete; // Disabled assign operator

void push_front(value_type&& item) {
std::unique_lock<std::mutex> lock(mutex_);
not_full_.wait(lock, [&] { return is_not_full(); });
Expand All @@ -69,9 +72,6 @@ class BoundedBuffer {
}

private:
BoundedBuffer(const BoundedBuffer&) = delete; // Disabled copy constructor
BoundedBuffer& operator=(const BoundedBuffer&) = delete; // Disabled assign operator

bool is_not_empty() const { return unread_ > 0; }
bool is_not_full() const { return unread_ < capacity_; }

Expand Down
8 changes: 4 additions & 4 deletions silkworm/infra/common/bounded_buffer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ using namespace std::this_thread; // sleep_for, sleep_until
using namespace std::chrono_literals; // ns, us, ms, s, h, etc.
using std::chrono::system_clock;

double CalculatePi(int depth) {
double CalculatePi(long depth) {
double pi = 0.0;
for (int i = 0; i < depth; ++i) {
double numerator = static_cast<double>(((i % 2) * 2) - 1);
double denominator = static_cast<double>((2 * i) - 1);
for (long i = 0; i < depth; ++i) {
auto numerator = static_cast<double>(((i % 2) * 2) - 1);
auto denominator = static_cast<double>((2 * i) - 1);
pi += numerator / denominator;
}
return (pi - 1.0) * 4;
Expand Down

0 comments on commit 10207dd

Please sign in to comment.