Skip to content

Commit

Permalink
Merge pull request Tencent#93 from linxiaocong/master
Browse files Browse the repository at this point in the history
replace static array g_arrCoEnvPerThread with thread local var. fixed Tencent#85 Tencent#93
  • Loading branch information
leiffyli authored Dec 20, 2018
2 parents f38e101 + c6f6633 commit 6d49ec7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions co_routine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,12 +701,12 @@ static short EpollEvent2Poll( uint32_t events )
return e;
}

static stCoRoutineEnv_t* g_arrCoEnvPerThread[ 204800 ] = { 0 };
static __thread stCoRoutineEnv_t* gCoEnvPerThread = NULL;

void co_init_curr_thread_env()
{
pid_t pid = GetPid();
g_arrCoEnvPerThread[ pid ] = (stCoRoutineEnv_t*)calloc( 1,sizeof(stCoRoutineEnv_t) );
stCoRoutineEnv_t *env = g_arrCoEnvPerThread[ pid ];
gCoEnvPerThread = (stCoRoutineEnv_t*)calloc( 1, sizeof(stCoRoutineEnv_t) );
stCoRoutineEnv_t *env = gCoEnvPerThread;

env->iCallStackSize = 0;
struct stCoRoutine_t *self = co_create_env( env, NULL, NULL,NULL );
Expand All @@ -724,7 +724,7 @@ void co_init_curr_thread_env()
}
stCoRoutineEnv_t *co_get_curr_thread_env()
{
return g_arrCoEnvPerThread[ GetPid() ];
return gCoEnvPerThread;
}

void OnPollProcessEvent( stTimeoutItem_t * ap )
Expand Down

0 comments on commit 6d49ec7

Please sign in to comment.