| 588 | } |
| 589 | |
| 590 | void 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 | |
| 615 | TEST_F(ExecutionQueueTest, inplace_and_order) { |
| 616 | for (int i = 0; i < 2; ++i) { |
no test coverage detected