Skip to content

Commit

Permalink
fix: hotfixes
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
  • Loading branch information
xDimon committed Feb 6, 2024
1 parent 35cc23e commit 58a60b3
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 89 deletions.
65 changes: 0 additions & 65 deletions include/soralog/common.hpp

This file was deleted.

1 change: 0 additions & 1 deletion include/soralog/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <fmt/format.h>
#include <fmt/ostream.h>

#include <soralog/common.hpp>
#include <soralog/level.hpp>
#include <soralog/sink.hpp>
#include <soralog/util.hpp>
Expand Down
3 changes: 1 addition & 2 deletions include/soralog/sink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <fmt/format.h>

#include <soralog/circular_buffer.hpp>
#include <soralog/common.hpp>
#include <soralog/event.hpp>

#ifdef NDEBUG
Expand All @@ -24,7 +23,7 @@
#endif

#if not defined(likely_if)
#if __cplusplus > 201703L
#if __cplusplus >= 202002L
#define likely_if(x) [[likely]] if (x)
#elif defined(__has_builtin)
#if __has_builtin(__builtin_expect)
Expand Down
2 changes: 0 additions & 2 deletions src/impl/sink_to_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#include <fmt/color.h>
#include <fmt/format.h>

#include <soralog/common.hpp>

namespace soralog {

namespace {
Expand Down
36 changes: 18 additions & 18 deletions test/unit/circular_buffer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#include <gtest/gtest.h>

#if __cplusplus > 201703L
#include <barrier>
#if __cplusplus >= 202002L
#include <latch>
#endif

#include "soralog/impl/sink_to_file.hpp"
Expand Down Expand Up @@ -159,13 +159,13 @@ TEST_F(CircularBufferTest, PutGetMt) {
std::atomic_size_t i = 0;
std::atomic_size_t n = 100;

#if __cplusplus > 201703L
std::barrier barrier(3);
#if __cplusplus >= 202002L
std::latch latch(3);
#endif

std::thread prod([&] {
#if __cplusplus > 201703L
barrier.arrive_and_wait();
#if __cplusplus >= 202002L
latch.arrive_and_wait();
#endif
while (i < n) {
std::cout << "w" << i << std::endl;
Expand All @@ -181,8 +181,8 @@ TEST_F(CircularBufferTest, PutGetMt) {
});

std::thread cons([&] {
#if __cplusplus > 201703L
barrier.arrive_and_wait();
#if __cplusplus >= 202002L
latch.arrive_and_wait();
#endif
while (i < n) {
std::cout << "r" << std::endl;
Expand All @@ -195,8 +195,8 @@ TEST_F(CircularBufferTest, PutGetMt) {
}
});

#if __cplusplus > 201703L
barrier.arrive_and_wait();
#if __cplusplus >= 202002L
latch.arrive_and_wait();
#endif
prod.join();
cons.join();
Expand All @@ -207,13 +207,13 @@ TEST_F(CircularBufferTest, Mutual) {

CircularBuffer<Data> testee(capacity);

#if __cplusplus > 201703L
std::barrier barrier(3);
#if __cplusplus >= 202002L
std::latch latch(3);
#endif

std::thread prod([&] {
#if __cplusplus > 201703L
barrier.arrive_and_wait();
#if __cplusplus >= 202002L
latch.arrive_and_wait();
#endif
if (auto ref = testee.put('*')) {
std::cout << "put " << ref->c() //
Expand All @@ -224,8 +224,8 @@ TEST_F(CircularBufferTest, Mutual) {
});

std::thread cons([&] {
#if __cplusplus > 201703L
barrier.arrive_and_wait();
#if __cplusplus >= 202002L
latch.arrive_and_wait();
#endif
std::this_thread::sleep_for(std::chrono::milliseconds(50));
if (auto ref = testee.get()) {
Expand All @@ -235,8 +235,8 @@ TEST_F(CircularBufferTest, Mutual) {
}
});

#if __cplusplus > 201703L
barrier.arrive_and_wait();
#if __cplusplus >= 202002L
latch.arrive_and_wait();
#endif
prod.join();
cons.join();
Expand Down
2 changes: 1 addition & 1 deletion test/unit/macros_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MacrosTest : public ::testing::Test {
void log(Level lvl, const Format &format, Args &&...args) {
last_level = lvl;
size_t len =
fmt::vformat_to_n(
::fmt::vformat_to_n(
message_buf.begin(), message_buf.size(),
::fmt::detail_exported::compile_string_to_view<char>(format),
::fmt::make_format_args(args...))
Expand Down
6 changes: 6 additions & 0 deletions test/unit/sink_to_console_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

#include "soralog/impl/sink_to_console.hpp"

#if __cplusplus >= 202002L
#include <latch>
#endif

using namespace soralog;
using namespace testing;
Expand Down Expand Up @@ -116,10 +118,14 @@ TEST_F(SinkToConsoleTest, MultithreadLogging) {
size_t treads_n = 10;
size_t iters_n = 100;

#if __cplusplus >= 202002L
std::latch latch(treads_n);
#endif

auto task = [&] {
#if __cplusplus >= 202002L
latch.arrive_and_wait();
#endif
std::mutex m;
for (auto i = 0; i < iters_n; ++i) {
logger->debug("iteration {}.1", i);
Expand Down

0 comments on commit 58a60b3

Please sign in to comment.