| 517 | } |
| 518 | |
| 519 | int stuck_and_check_running_thread(void* arg, bthread::TaskIterator<InPlaceTask>& iter) { |
| 520 | if (iter.is_queue_stopped()) { |
| 521 | return 0; |
| 522 | } |
| 523 | butil::atomic<int>* futex = (butil::atomic<int>*)arg; |
| 524 | if (iter->first_task) { |
| 525 | EXPECT_EQ(pthread_self(), iter->thread_id); |
| 526 | futex->store(1); |
| 527 | bthread::futex_wake_private(futex, 1); |
| 528 | while (futex->load() != 2) { |
| 529 | bthread::futex_wait_private(futex, 1, NULL); |
| 530 | } |
| 531 | ++iter; |
| 532 | EXPECT_FALSE(iter); |
| 533 | } else { |
| 534 | for (; iter; ++iter) { |
| 535 | EXPECT_FALSE(iter->first_task); |
| 536 | EXPECT_NE(pthread_self(), iter->thread_id); |
| 537 | } |
| 538 | } |
| 539 | return 0; |
| 540 | } |
| 541 | |
| 542 | void test_should_start_new_thread_on_more_tasks(bool use_pthread) { |
| 543 | bthread::ExecutionQueueId<InPlaceTask> queue_id = { 0 }; |
nothing calls this directly
no test coverage detected