Core: Refine yield for high performance timer. · ossrs/state-threads@387cddb

Original file line numberDiff line numberDiff line change

@@ -67,6 +67,7 @@ unsigned long long _st_stat_sched_s = 0;

6767

unsigned long long _st_stat_thread_run = 0;

6868

unsigned long long _st_stat_thread_idle = 0;

6969

unsigned long long _st_stat_thread_yield = 0;

70+

unsigned long long _st_stat_thread_yield2 = 0;

7071

#endif

7172
7273

@@ -559,18 +560,22 @@ void st_thread_yield()

559560

{

560561

_st_thread_t *me = _ST_CURRENT_THREAD();

561562
563+

#ifdef DEBUG

564+

++_st_stat_thread_yield;

565+

#endif

566+
567+

/* Check sleep queue for expired threads */

568+

_st_vp_check_clock();

569+
562570

// If not thread in RunQ to yield to, ignore and continue to run.

563571

if (_ST_RUNQ.next == &_ST_RUNQ) {

564572

return;

565573

}

566574
567575

#ifdef DEBUG

568-

++_st_stat_thread_yield;

576+

++_st_stat_thread_yield2;

569577

#endif

570578
571-

/* Check sleep queue for expired threads */

572-

_st_vp_check_clock();

573-
574579

// Append thread to the tail of RunQ, we will back after all threads executed.

575580

me->state = _ST_ST_RUNNABLE;

576581

_ST_ADD_RUNQ(me);