Skip to content

Commit

Permalink
For #2194, Support ST yield
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Feb 19, 2021
1 parent 0168769 commit c0fda42
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions trunk/src/app/srs_app_hybrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ SrsPps* _srs_pps_timer_s = new SrsPps(_srs_clock);
extern int _st_active_count;
extern unsigned long long _st_stat_thread_run;
extern unsigned long long _st_stat_thread_idle;
extern unsigned long long _st_stat_thread_yield;
SrsPps* _srs_pps_thread_run = new SrsPps(_srs_clock);
SrsPps* _srs_pps_thread_idle = new SrsPps(_srs_clock);
SrsPps* _srs_pps_thread_yield = new SrsPps(_srs_clock);

ISrsHybridServer::ISrsHybridServer()
{
Expand Down Expand Up @@ -428,8 +430,9 @@ srs_error_t SrsHybridServer::notify(int event, srs_utime_t interval, srs_utime_t

string thread_desc;
_srs_pps_thread_run->update(_st_stat_thread_run); _srs_pps_thread_idle->update(_st_stat_thread_idle);
if (_st_active_count > 0 || _srs_pps_thread_run->r10s() || _srs_pps_thread_idle->r10s()) {
snprintf(buf, sizeof(buf), ", co=%d,%d,%d", _st_active_count, _srs_pps_thread_run->r10s(), _srs_pps_thread_idle->r10s());
_srs_pps_thread_yield->update(_st_stat_thread_yield);
if (_st_active_count > 0 || _srs_pps_thread_run->r10s() || _srs_pps_thread_idle->r10s() || _srs_pps_thread_yield->r10s()) {
snprintf(buf, sizeof(buf), ", co=%d,%d,%d,%d", _st_active_count, _srs_pps_thread_run->r10s(), _srs_pps_thread_idle->r10s(), _srs_pps_thread_yield->r10s());
thread_desc = buf;
}

Expand Down
5 changes: 5 additions & 0 deletions trunk/src/protocol/srs_service_st.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ void srs_thread_exit(void* retval)
st_thread_exit(retval);
}

void srs_thread_yield()
{
st_thread_yield();
}

srs_error_t srs_tcp_connect(string server, int port, srs_utime_t tm, srs_netfd_t* pstfd)
{
st_utime_t timeout = ST_UTIME_NO_TIMEOUT;
Expand Down
1 change: 1 addition & 0 deletions trunk/src/protocol/srs_service_st.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ extern srs_error_t srs_fd_keepalive(int fd);
// Get current coroutine/thread.
extern srs_thread_t srs_thread_self();
extern void srs_thread_exit(void* retval);
extern void srs_thread_yield();

// For client, to open socket and connect to server.
// @param tm The timeout in srs_utime_t.
Expand Down

0 comments on commit c0fda42

Please sign in to comment.