@@ -19,7 +19,6 @@ limitations under the License. */
1919
2020#include " gtest/gtest.h"
2121
22-
2322using paddle::framework::Channel;
2423using paddle::framework::MakeChannel;
2524using paddle::framework::CloseChannel;
@@ -47,12 +46,12 @@ TEST(Channel, SufficientBufferSizeDoesntBlock) {
4746 const size_t buffer_size = 10 ;
4847 auto ch = MakeChannel<size_t >(buffer_size);
4948 for (size_t i = 0 ; i < buffer_size; ++i) {
50- ch->Send (&i); // should not block
49+ ch->Send (&i); // should not block
5150 }
5251
5352 size_t out;
5453 for (size_t i = 0 ; i < buffer_size; ++i) {
55- ch->Receive (&out); // should not block
54+ ch->Receive (&out); // should not block
5655 EXPECT_EQ (out, i);
5756 }
5857 CloseChannel (ch);
@@ -63,15 +62,14 @@ TEST(Channel, ConcurrentSendNonConcurrentReceiveWithSufficientBufferSize) {
6362 auto ch = MakeChannel<size_t >(buffer_size);
6463
6564 size_t sum = 0 ;
66- std::thread t ([&](){
67- // Try to write more than buffer size.
68- for (size_t i = 0 ; i < 2 *buffer_size; ++i) {
69- ch->Send (&i); // should not block
70- sum += i;
71- }
72- });
73-
74- std::this_thread::sleep_for (std::chrono::milliseconds (100 )); // wait 0.5 sec
65+ std::thread t ([&]() {
66+ // Try to write more than buffer size.
67+ for (size_t i = 0 ; i < 2 * buffer_size; ++i) {
68+ ch->Send (&i); // should not block
69+ sum += i;
70+ }
71+ });
72+ std::this_thread::sleep_for (std::chrono::milliseconds (100 )); // wait 0.5 sec
7573 EXPECT_EQ (sum, 45U );
7674 CloseChannel (ch);
7775}
0 commit comments