1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Log: Use object as context id for complex context

This commit is contained in:
winlin 2020-07-05 23:26:55 +08:00
parent bff7ef085d
commit 6624b8acca
34 changed files with 276 additions and 238 deletions

View file

@ -74,18 +74,27 @@ srs_error_t SrsDummyCoroutine::pull()
return srs_error_new(ERROR_THREAD_DUMMY, "dummy pull");
}
string SrsDummyCoroutine::cid()
SrsContextId SrsDummyCoroutine::cid()
{
return "";
return SrsContextId();
}
_ST_THREAD_CREATE_PFN _pfn_st_thread_create = (_ST_THREAD_CREATE_PFN)st_thread_create;
SrsSTCoroutine::SrsSTCoroutine(string n, ISrsCoroutineHandler* h, std::string cid)
SrsSTCoroutine::SrsSTCoroutine(string n, ISrsCoroutineHandler* h)
{
name = n;
handler = h;
context = cid;
trd = NULL;
trd_err = srs_success;
started = interrupted = disposed = cycle_done = false;
}
SrsSTCoroutine::SrsSTCoroutine(string n, ISrsCoroutineHandler* h, SrsContextId cid)
{
name = n;
handler = h;
cid_ = cid;
trd = NULL;
trd_err = srs_success;
started = interrupted = disposed = cycle_done = false;
@ -180,18 +189,18 @@ srs_error_t SrsSTCoroutine::pull()
return srs_error_copy(trd_err);
}
string SrsSTCoroutine::cid()
SrsContextId SrsSTCoroutine::cid()
{
return context;
return cid_;
}
srs_error_t SrsSTCoroutine::cycle()
{
if (_srs_context) {
if (!context.empty()) {
_srs_context->set_id(context);
if (!cid_.empty()) {
_srs_context->set_id(cid_);
} else {
context = _srs_context->generate_id();
cid_ = _srs_context->generate_id();
}
}