Skip to content

Commit

Permalink
fix incorrect error code returned
Browse files Browse the repository at this point in the history
  • Loading branch information
theartful committed Sep 15, 2023
1 parent 25cbc28 commit f1c8a07
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ of the disruptor pattern in C++.

* [Can Seqlocks Get Along With Programming Language Memory Models?][1]
* [Trading at light speed: designing low latency systems in C++ - David Gross - Meeting C++ 2022][2]
* [LMAX Disruptor and the Concepts of Mechanical Sympathy] [3]
* [LMAX Disruptor and the Concepts of Mechanical Sympathy][3]
* [Building a Lock-free Multi-producer, Multi-consumer Queue for Tcmalloc - Matt Kulukundis - CppCon 21][4]
* [Flat Combining and the Synchronization-Parallelism Tradeoff][5]

Expand Down
4 changes: 2 additions & 2 deletions broadcast_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ class queue_data<T, WaitingStrategy,
auto refcount = block->refcount.load(std::memory_order_relaxed);
// the block died from underneath us!
if (refcount == 0) {
return Error::Timeout;
return Error::Lagged;
}

// try to increment refcount so that no one will dare destroy the object
Expand All @@ -537,7 +537,7 @@ class queue_data<T, WaitingStrategy,
std::memory_order_relaxed)) {
// the block died from underneath us!
if (refcount == 0) {
return Error::Timeout;
return Error::Lagged;
}
}

Expand Down
25 changes: 14 additions & 11 deletions tests/multi_threaded_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,24 @@ template <typename T, typename WaitingStrategy> struct TestTypes {
};

using MyTypes = ::testing::Types<
TestTypes<int, broadcast_queue::default_waiting_strategy>,
TestTypes<float, broadcast_queue::default_waiting_strategy>,
TestTypes<std::array<char, 16>, broadcast_queue::default_waiting_strategy>,
TestTypes<int, broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<float, broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<std::array<char, 16>,
broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<std::array<char, 1024>,
broadcast_queue::default_waiting_strategy>,
broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<std::array<char, 2048>,
broadcast_queue::default_waiting_strategy>,
TestTypes<int, broadcast_queue::default_waiting_strategy>,
TestTypes<float, broadcast_queue::default_waiting_strategy>,
TestTypes<std::array<char, 16>, broadcast_queue::default_waiting_strategy>,
broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<int, broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<float, broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<std::array<char, 16>,
broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<std::array<char, 1024>,
broadcast_queue::default_waiting_strategy>,
broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<std::array<char, 2048>,
broadcast_queue::default_waiting_strategy>,
TestTypes<std::string, broadcast_queue::default_waiting_strategy>,
broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<std::string,
broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<int, broadcast_queue::semaphore_waiting_strategy>,
TestTypes<float, broadcast_queue::semaphore_waiting_strategy>,
TestTypes<std::array<char, 16>,
Expand Down
22 changes: 12 additions & 10 deletions tests/single_threaded_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,22 @@ template <typename T, typename WaitingStrategy> struct TestTypes {
};

using MyTypes = ::testing::Types<
TestTypes<int, broadcast_queue::default_waiting_strategy>,
TestTypes<float, broadcast_queue::default_waiting_strategy>,
TestTypes<std::array<char, 16>, broadcast_queue::default_waiting_strategy>,
TestTypes<int, broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<float, broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<std::array<char, 16>,
broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<std::array<char, 1024>,
broadcast_queue::default_waiting_strategy>,
broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<std::array<char, 2048>,
broadcast_queue::default_waiting_strategy>,
TestTypes<int, broadcast_queue::default_waiting_strategy>,
TestTypes<float, broadcast_queue::default_waiting_strategy>,
TestTypes<std::array<char, 16>, broadcast_queue::default_waiting_strategy>,
broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<int, broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<float, broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<std::array<char, 16>,
broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<std::array<char, 1024>,
broadcast_queue::default_waiting_strategy>,
broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<std::array<char, 2048>,
broadcast_queue::default_waiting_strategy>,
broadcast_queue::condition_variable_waiting_strategy>,
TestTypes<int, broadcast_queue::semaphore_waiting_strategy>,
TestTypes<float, broadcast_queue::semaphore_waiting_strategy>,
TestTypes<std::array<char, 16>,
Expand Down

0 comments on commit f1c8a07

Please sign in to comment.