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:
102
102
103
103
- name : Build
104
104
working-directory : ${{github.workspace}}/build
105
- run : cmake --build . --config Debug --target tests
105
+ run : cmake --build . --config Debug --target tests -j
106
106
107
107
- name : Test
108
108
working-directory : ${{github.workspace}}/build
109
- run : ctest -C Debug --verbose -R channel_test
109
+ run : ctest -C Debug --verbose -R channel_test -j
110
110
111
111
- name : Upload coverage reports to Codecov
112
112
uses : codecov/codecov-action@v5
Original file line number Diff line number Diff line change @@ -49,6 +49,39 @@ TEST(ChannelTest, PushAndFetch)
49
49
EXPECT_EQ (4 , out);
50
50
}
51
51
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
+
52
85
TEST (ChannelTest, PushAndFetchMultiple)
53
86
{
54
87
msd::channel<int > channel;
You can’t perform that action at this time.
0 commit comments