| 118 | } |
| 119 | |
| 120 | void 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 | |
| 147 | TEST_F(ExecutionQueueTest, rvalue) { |
| 148 | for (int i = 0; i < 2; ++i) { |
no test coverage detected