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

Function stuck_and_check_running_thread

test/bthread_execution_queue_unittest.cpp:519–540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

517}
518
519int 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
542void test_should_start_new_thread_on_more_tasks(bool use_pthread) {
543 bthread::ExecutionQueueId<InPlaceTask> queue_id = { 0 };

Callers

nothing calls this directly

Calls 5

is_queue_stoppedMethod · 0.80
futex_wake_privateFunction · 0.50
futex_wait_privateFunction · 0.50
storeMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected