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

Function test_multi_threaded_order

test/bthread_execution_queue_unittest.cpp:439–462  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

437}
438
439void test_multi_threaded_order(bool use_pthread) {
440 memset(next_task, 0, sizeof(next_task));
441 long disorder_times = 0;
442 bthread::ExecutionQueueId<LongIntTask> queue_id = { 0 }; // to suppress warnings
443 bthread::ExecutionQueueOptions options;
444 options.use_pthread = use_pthread;
445 if (options.use_pthread) {
446 LOG(INFO) << "================ pthread ================";
447 } else {
448 LOG(INFO) << "================ bthread ================";
449 }
450 ASSERT_EQ(0, bthread::execution_queue_start(&queue_id, &options,
451 check_order, &disorder_times));
452 pthread_t threads[12];
453 for (size_t i = 0; i < ARRAY_SIZE(threads); ++i) {
454 pthread_create(&threads[i], NULL, &push_thread_with_id, (void *)queue_id.value);
455 }
456 for (size_t i = 0; i < ARRAY_SIZE(threads); ++i) {
457 pthread_join(threads[i], NULL);
458 }
459 ASSERT_EQ(0, bthread::execution_queue_stop(queue_id));
460 ASSERT_EQ(0, bthread::execution_queue_join(queue_id));
461 ASSERT_EQ(0, disorder_times);
462}
463
464TEST_F(ExecutionQueueTest, multi_threaded_order) {
465 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