mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #2194, Core: Refine yield for high performance timer.
This commit is contained in:
parent
4fc1a19415
commit
a04dd7ed30
3 changed files with 16 additions and 8 deletions
15
trunk/3rdparty/st-srs/sched.c
vendored
15
trunk/3rdparty/st-srs/sched.c
vendored
|
@ -67,6 +67,7 @@ unsigned long long _st_stat_sched_s = 0;
|
|||
unsigned long long _st_stat_thread_run = 0;
|
||||
unsigned long long _st_stat_thread_idle = 0;
|
||||
unsigned long long _st_stat_thread_yield = 0;
|
||||
unsigned long long _st_stat_thread_yield2 = 0;
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -559,11 +560,6 @@ void st_thread_yield()
|
|||
{
|
||||
_st_thread_t *me = _ST_CURRENT_THREAD();
|
||||
|
||||
// If not thread in RunQ to yield to, ignore and continue to run.
|
||||
if (_ST_RUNQ.next == &_ST_RUNQ) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
++_st_stat_thread_yield;
|
||||
#endif
|
||||
|
@ -571,6 +567,15 @@ void st_thread_yield()
|
|||
/* Check sleep queue for expired threads */
|
||||
_st_vp_check_clock();
|
||||
|
||||
// If not thread in RunQ to yield to, ignore and continue to run.
|
||||
if (_ST_RUNQ.next == &_ST_RUNQ) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
++_st_stat_thread_yield2;
|
||||
#endif
|
||||
|
||||
// Append thread to the tail of RunQ, we will back after all threads executed.
|
||||
me->state = _ST_ST_RUNNABLE;
|
||||
_ST_ADD_RUNQ(me);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue