summaryrefslogtreecommitdiff
path: root/protocols/Telegram/tdlib/td/tdutils/test/MpmcQueue.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Telegram/tdlib/td/tdutils/test/MpmcQueue.cpp')
-rw-r--r--protocols/Telegram/tdlib/td/tdutils/test/MpmcQueue.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/protocols/Telegram/tdlib/td/tdutils/test/MpmcQueue.cpp b/protocols/Telegram/tdlib/td/tdutils/test/MpmcQueue.cpp
index 2da3f0cd3f..c038303c37 100644
--- a/protocols/Telegram/tdlib/td/tdutils/test/MpmcQueue.cpp
+++ b/protocols/Telegram/tdlib/td/tdutils/test/MpmcQueue.cpp
@@ -1,9 +1,10 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
+#include "td/utils/common.h"
#include "td/utils/logging.h"
#include "td/utils/MpmcQueue.h"
#include "td/utils/port/thread.h"
@@ -49,7 +50,7 @@ TEST(OneValue, stress) {
std::vector<td::thread> threads;
td::OneValue<std::string> value;
for (size_t i = 0; i < 2; i++) {
- threads.push_back(td::thread([&, id = i] {
+ threads.emplace_back([&, id = i] {
for (td::uint64 round = 1; round < 100000; round++) {
if (id == 0) {
value.reset();
@@ -68,7 +69,7 @@ TEST(OneValue, stress) {
if (set_status) {
CHECK(get_status);
CHECK(from.empty());
- CHECK(to == "hello") << to;
+ LOG_CHECK(to == "hello") << to;
} else {
CHECK(!get_status);
CHECK(from == "hello");
@@ -76,17 +77,17 @@ TEST(OneValue, stress) {
}
}
}
- }));
+ });
}
for (auto &thread : threads) {
thread.join();
}
}
-#endif //!TD_THREAD_UNSUPPORTED
+#endif
TEST(MpmcQueueBlock, simple) {
// Test doesn't work now and it is ok, try_pop, logic changed
- return;
+ /*
td::MpmcQueueBlock<std::string> block(2);
std::string x = "hello";
using PushStatus = td::MpmcQueueBlock<std::string>::PushStatus;
@@ -111,6 +112,7 @@ TEST(MpmcQueueBlock, simple) {
CHECK(pop_status == PopStatus::Ok);
pop_status = block.try_pop(x);
CHECK(pop_status == PopStatus::Closed);
+ */
}
TEST(MpmcQueue, simple) {
@@ -121,7 +123,7 @@ TEST(MpmcQueue, simple) {
}
for (int i = 0; i < 100; i++) {
int x = q.pop(0);
- CHECK(x == i) << x << " expected " << i;
+ LOG_CHECK(x == i) << x << " expected " << i;
}
}
}
@@ -188,18 +190,18 @@ TEST(MpmcQueue, multi_thread) {
from[data.from] = data.value;
}
}
- CHECK(all.size() == n * qn) << all.size();
+ LOG_CHECK(all.size() == n * qn) << all.size();
std::sort(all.begin(), all.end(),
[](const auto &a, const auto &b) { return std::tie(a.from, a.value) < std::tie(b.from, b.value); });
for (size_t i = 0; i < n * qn; i++) {
CHECK(all[i].from == i / qn);
CHECK(all[i].value == i % qn + 1);
}
- LOG(ERROR) << "Undeleted pointers: " << q.hazard_pointers_to_delele_size_unsafe();
+ LOG(INFO) << "Undeleted pointers: " << q.hazard_pointers_to_delele_size_unsafe();
CHECK(q.hazard_pointers_to_delele_size_unsafe() <= (n + m + 1) * (n + m + 1));
for (size_t id = 0; id < n + m + 1; id++) {
q.gc(id);
}
- CHECK(q.hazard_pointers_to_delele_size_unsafe() == 0) << q.hazard_pointers_to_delele_size_unsafe();
+ LOG_CHECK(q.hazard_pointers_to_delele_size_unsafe() == 0) << q.hazard_pointers_to_delele_size_unsafe();
}
-#endif //!TD_THREAD_UNSUPPORTED
+#endif