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

Function test_rvalue

test/bthread_execution_queue_unittest.cpp:120–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120void test_rvalue(bool use_pthread) {
121 int64_t result = 0;
122 int64_t expected_result = 0;
123 stopped = false;
124 bthread::ExecutionQueueId<RValue> queue_id;
125 bthread::ExecutionQueueOptions options;
126 options.use_pthread = use_pthread;
127 if (options.use_pthread) {
128 LOG(INFO) << "================ pthread ================";
129 } else {
130 LOG(INFO) << "================ bthread ================";
131 }
132 ASSERT_EQ(0, bthread::execution_queue_start(&queue_id, &options,
133 add, &result));
134 for (int i = 0; i < 100; ++i) {
135 expected_result += i;
136 RValue v(i);
137 ASSERT_EQ(0, bthread::execution_queue_execute(queue_id, std::move(v)));
138 }
139 LOG(INFO) << "stop";
140 ASSERT_EQ(0, bthread::execution_queue_stop(queue_id));
141 ASSERT_NE(0, bthread::execution_queue_execute(queue_id, RValue(0)));
142 ASSERT_EQ(0, bthread::execution_queue_join(queue_id));
143 ASSERT_EQ(expected_result, result);
144 ASSERT_TRUE(stopped);
145}
146
147TEST_F(ExecutionQueueTest, rvalue) {
148 for (int i = 0; i < 2; ++i) {

Callers 1

TEST_FFunction · 0.85

Calls 6

execution_queue_startFunction · 0.85
execution_queue_executeFunction · 0.85
execution_queue_stopFunction · 0.85
RValueClass · 0.85
execution_queue_joinFunction · 0.85
moveFunction · 0.50

Tested by

no test coverage detected