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

Original file line number Diff line number Diff line change
@@ -67,6 +67,7 @@ unsigned long long _st_stat_sched_s = 0;
67 67 unsigned long long _st_stat_thread_run = 0;
68 68 unsigned long long _st_stat_thread_idle = 0;
69 69 unsigned long long _st_stat_thread_yield = 0;
70 +unsigned long long _st_stat_thread_yield2 = 0;
70 71 #endif
71 72
72 73
@@ -559,18 +560,22 @@ void st_thread_yield()
559 560 {
560 561 _st_thread_t *me = _ST_CURRENT_THREAD();
561 562
563 +#ifdef DEBUG
564 +++_st_stat_thread_yield;
565 +#endif
566 +
567 +/* Check sleep queue for expired threads */
568 +_st_vp_check_clock();
569 +
562 570 // If not thread in RunQ to yield to, ignore and continue to run.
563 571 if (_ST_RUNQ.next == &_ST_RUNQ) {
564 572 return;
565 573 }
566 574
567 575 #ifdef DEBUG
568 -++_st_stat_thread_yield;
576 +++_st_stat_thread_yield2;
569 577 #endif
570 578
571 -/* Check sleep queue for expired threads */
572 -_st_vp_check_clock();
573 -
574 579 // Append thread to the tail of RunQ, we will back after all threads executed.
575 580 me->state = _ST_ST_RUNNABLE;
576 581 _ST_ADD_RUNQ(me);