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

ST: Allow set the default stack size

This commit is contained in:
winlin 2020-10-22 17:06:36 +08:00
parent a14f26971b
commit 97880f6bb7
3 changed files with 21 additions and 2 deletions

View file

@ -83,11 +83,15 @@ _ST_THREAD_CREATE_PFN _pfn_st_thread_create = (_ST_THREAD_CREATE_PFN)st_thread_c
SrsSTCoroutine::SrsSTCoroutine(string n, ISrsCoroutineHandler* h)
{
// TODO: FIXME: Reduce duplicated code.
name = n;
handler = h;
trd = NULL;
trd_err = srs_success;
started = interrupted = disposed = cycle_done = false;
// 0 use default, default is 64K.
stack_size = 0;
}
SrsSTCoroutine::SrsSTCoroutine(string n, ISrsCoroutineHandler* h, SrsContextId cid)
@ -98,6 +102,9 @@ SrsSTCoroutine::SrsSTCoroutine(string n, ISrsCoroutineHandler* h, SrsContextId c
trd = NULL;
trd_err = srs_success;
started = interrupted = disposed = cycle_done = false;
// 0 use default, default is 64K.
stack_size = 0;
}
SrsSTCoroutine::~SrsSTCoroutine()
@ -107,6 +114,11 @@ SrsSTCoroutine::~SrsSTCoroutine()
srs_freep(trd_err);
}
void SrsSTCoroutine::set_stack_size(int v)
{
stack_size = v;
}
srs_error_t SrsSTCoroutine::start()
{
srs_error_t err = srs_success;
@ -124,8 +136,8 @@ srs_error_t SrsSTCoroutine::start()
return err;
}
if ((trd = (srs_thread_t)_pfn_st_thread_create(pfn, this, 1, 0)) == NULL) {
if ((trd = (srs_thread_t)_pfn_st_thread_create(pfn, this, 1, stack_size)) == NULL) {
err = srs_error_new(ERROR_ST_CREATE_CYCLE_THREAD, "create failed");
srs_freep(trd_err);