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

Function test_inplace_and_order

test/bthread_execution_queue_unittest.cpp:590–613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

588}
589
590void test_inplace_and_order(bool use_pthread) {
591 memset(next_task, 0, sizeof(next_task));
592 long disorder_times = 0;
593 bthread::ExecutionQueueId<LongIntTask> queue_id = { 0 }; // to suppress warnings
594 bthread::ExecutionQueueOptions options;
595 options.use_pthread = use_pthread;
596 if (options.use_pthread) {
597 LOG(INFO) << "================ pthread ================";
598 } else {
599 LOG(INFO) << "================ bthread ================";
600 }
601 ASSERT_EQ(0, bthread::execution_queue_start(&queue_id, &options,
602 check_order, &disorder_times));
603 pthread_t threads[12];
604 for (size_t i = 0; i < ARRAY_SIZE(threads); ++i) {
605 pthread_create(&threads[i], NULL, &inplace_push_thread, (void *)queue_id.value);
606 }
607 for (size_t i = 0; i < ARRAY_SIZE(threads); ++i) {
608 pthread_join(threads[i], NULL);
609 }
610 ASSERT_EQ(0, bthread::execution_queue_stop(queue_id));
611 ASSERT_EQ(0, bthread::execution_queue_join(queue_id));
612 ASSERT_EQ(0, disorder_times);
613}
614
615TEST_F(ExecutionQueueTest, inplace_and_order) {
616 for (int i = 0; i < 2; ++i) {

Callers 1

TEST_FFunction · 0.85

Calls 3

execution_queue_startFunction · 0.85
execution_queue_stopFunction · 0.85
execution_queue_joinFunction · 0.85

Tested by

no test coverage detected