From 6cbddcba39e871be2f58fffdd0546b480e41f24e Mon Sep 17 00:00:00 2001 From: gabime Date: Sun, 8 Dec 2024 23:03:12 +0200 Subject: [PATCH] Fix tests --- tests/test_async.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_async.cpp b/tests/test_async.cpp index 63dbdd4d..6d373527 100644 --- a/tests/test_async.cpp +++ b/tests/test_async.cpp @@ -113,11 +113,12 @@ TEST_CASE("multi threads", "[async]") { size_t n_threads = 10; { auto [logger, async_sink] = creat_async_logger(queue_size, test_sink); + std::vector threads; for (size_t i = 0; i < n_threads; i++) { - threads.emplace_back([&] { - for (size_t j = 0; j < messages; j++) { - logger->info("Hello message #{}", j); + threads.emplace_back([l=logger, msgs = messages] { + for (size_t j = 0; j < msgs; j++) { + l->info("Hello message #{}", j); } }); logger->flush();