Skip to content

Commit 5cf7947

Browse files
Revert "Test waiting on full channel"
This reverts commit abfbb57.
1 parent abfbb57 commit 5cf7947

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

.github/workflows/cmake.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ jobs:
102102

103103
- name: Build
104104
working-directory: ${{github.workspace}}/build
105-
run: cmake --build . --config Debug --target tests -j
105+
run: cmake --build . --config Debug --target tests
106106

107107
- name: Test
108108
working-directory: ${{github.workspace}}/build
109-
run: ctest -C Debug --verbose -R channel_test -j
109+
run: ctest -C Debug --verbose -R channel_test
110110

111111
- name: Upload coverage reports to Codecov
112112
uses: codecov/codecov-action@v5

tests/channel_test.cpp

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ TEST(ChannelTest, Iterator)
148148

149149
TEST(ChannelTest, Multithreading)
150150
{
151-
const int numbers = 1000;
152-
const std::int64_t expected = 500500;
153-
constexpr std::size_t kThreadsToReadFrom = 50;
151+
const int numbers = 10000;
152+
const std::int64_t expected = 50005000;
153+
constexpr std::size_t kThreadsToReadFrom = 100;
154154

155155
msd::channel<int> channel{10};
156156

@@ -176,8 +176,6 @@ TEST(ChannelTest, Multithreading)
176176

177177
sum_numbers += out;
178178
++count_numbers;
179-
180-
std::this_thread::sleep_for(std::chrono::milliseconds(1));
181179
}
182180
--wait_counter;
183181
cond_wait.notify_one();
@@ -188,19 +186,16 @@ TEST(ChannelTest, Multithreading)
188186
threads.emplace_back(std::thread{worker});
189187
}
190188

191-
auto sender = [&] {
192-
// Send numbers to channel
193-
for (int i = 1; i <= numbers; ++i) {
194-
channel << i;
189+
// Send numbers to channel
190+
for (int i = 1; i <= numbers; ++i) {
191+
channel << i;
195192

196-
// Notify threads than then can start reading
197-
if (!ready_to_read) {
198-
ready_to_read = true;
199-
cond_read.notify_all();
200-
}
193+
// Notify threads than then can start reading
194+
if (!ready_to_read) {
195+
ready_to_read = true;
196+
cond_read.notify_all();
201197
}
202-
};
203-
threads.emplace_back(std::thread{sender});
198+
}
204199

205200
// Wait until all items have been read
206201
std::unique_lock<std::mutex> lock{mtx_wait};

0 commit comments

Comments
 (0)