Skip to content

Commit

Permalink
replace static array g_arrCoEnvPerThread with thread local var
Browse files Browse the repository at this point in the history
  • Loading branch information
charlielin committed Jul 4, 2018
1 parent 8ce6dfe commit c6f6633
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 c6f6633

Please sign in to comment.