File tree Expand file tree Collapse file tree 2 files changed +35
-2
lines changed
Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Original file line number Diff line number Diff 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
105+ run : cmake --build . --config Debug --target tests -j
106106
107107 - name : Test
108108 working-directory : ${{github.workspace}}/build
109- run : ctest -C Debug --verbose -R channel_test
109+ run : ctest -C Debug --verbose -R channel_test -j
110110
111111 - name : Upload coverage reports to Codecov
112112 uses : codecov/codecov-action@v5
Original file line number Diff line number Diff line change @@ -49,6 +49,39 @@ TEST(ChannelTest, PushAndFetch)
4949 EXPECT_EQ (4 , out);
5050}
5151
52+ TEST (ChannelTest, PushAndFetchWithBufferedChannel)
53+ {
54+ msd::channel<int > channel{2 };
55+
56+ auto push = [&channel]() {
57+ channel << 1 ;
58+ channel << 2 ;
59+ channel << 3 ;
60+ };
61+
62+ auto read = [&channel]() {
63+ // Wait before reading to test the case where the channel is full and waiting
64+ // for the reader to read some items.
65+ std::this_thread::sleep_for (std::chrono::milliseconds (100 ));
66+
67+ int out = 0 ;
68+
69+ channel >> out;
70+ EXPECT_EQ (1 , out);
71+
72+ channel >> out;
73+ EXPECT_EQ (2 , out);
74+
75+ channel >> out;
76+ EXPECT_EQ (3 , out);
77+ };
78+
79+ std::thread push_thread{push};
80+ std::thread read_thread{read};
81+ push_thread.join ();
82+ read_thread.join ();
83+ }
84+
5285TEST (ChannelTest, PushAndFetchMultiple)
5386{
5487 msd::channel<int > channel;
You can’t perform that action at this time.
0 commit comments