| 697 | } |
| 698 | |
| 699 | void test_cancel_self(bool use_pthread) { |
| 700 | bthread::ExecutionQueueId<CancelSelf*> queue_id = { 0 }; // to suppress warnings |
| 701 | bthread::ExecutionQueueOptions options; |
| 702 | options.use_pthread = use_pthread; |
| 703 | if (options.use_pthread) { |
| 704 | LOG(INFO) << "================ pthread ================"; |
| 705 | } else { |
| 706 | LOG(INFO) << "================ bthread ================"; |
| 707 | } |
| 708 | ASSERT_EQ(0, bthread::execution_queue_start(&queue_id, &options, |
| 709 | cancel_self, NULL)); |
| 710 | CancelSelf task; |
| 711 | task.handle = NULL; |
| 712 | bthread::TaskHandle handle; |
| 713 | ASSERT_EQ(0, bthread::execution_queue_execute(queue_id, &task, NULL, &handle)); |
| 714 | task.handle.store(&handle); |
| 715 | ASSERT_EQ(0, bthread::execution_queue_stop(queue_id)); |
| 716 | ASSERT_EQ(0, bthread::execution_queue_join(queue_id)); |
| 717 | } |
| 718 | |
| 719 | TEST_F(ExecutionQueueTest, cancel_self) { |
| 720 | for (int i = 0; i < 2; ++i) { |
no test coverage detected