MCPcopy Create free account
hub / github.com/apache/brpc / test_single_thread

Function test_single_thread

test/bthread_execution_queue_unittest.cpp:58–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58void test_single_thread(bool use_pthread) {
59 int64_t result = 0;
60 int64_t expected_result = 0;
61 stopped = false;
62 bthread::ExecutionQueueId<LongIntTask> queue_id;
63 bthread::ExecutionQueueOptions options;
64 options.use_pthread = use_pthread;
65 if (options.use_pthread) {
66 LOG(INFO) << "================ pthread ================";
67 } else {
68 LOG(INFO) << "================ bthread ================";
69 }
70 ASSERT_EQ(0, bthread::execution_queue_start(&queue_id, &options,
71 add, &result));
72 for (int i = 0; i < 100; ++i) {
73 expected_result += i;
74 ASSERT_EQ(0, bthread::execution_queue_execute(queue_id, i));
75 }
76 LOG(INFO) << "stop";
77 ASSERT_EQ(0, bthread::execution_queue_stop(queue_id));
78 ASSERT_NE(0, bthread::execution_queue_execute(queue_id, 0));
79 ASSERT_EQ(0, bthread::execution_queue_join(queue_id));
80 ASSERT_EQ(expected_result, result);
81 ASSERT_TRUE(stopped);
82}
83
84TEST_F(ExecutionQueueTest, single_thread) {
85 for (int i = 0; i < 2; ++i) {

Callers 1

TEST_FFunction · 0.85

Calls 4

execution_queue_startFunction · 0.85
execution_queue_executeFunction · 0.85
execution_queue_stopFunction · 0.85
execution_queue_joinFunction · 0.85

Tested by

no test coverage detected