give dict iter its own threadmap

I like this better than the previous fix: rather than share a
thread->env map with the game world allocate a new one for each
iterator. This could cause problem if the iterator is used on threads
that don't currently call map_thread(), or if there are callbacks that
need to look up the env that I'm not aware of. Needs testing...
This commit is contained in:
Eric House 2018-01-22 22:02:57 -08:00
parent 7242a709cb
commit d809ff4f7c

View file

@ -2084,7 +2084,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1sendChat
////////////////////////////////////////////////////////////
typedef struct _DictIterData {
JNIGlobalState* state;
EnvThreadInfo ti;
JNIEnv* env;
JNIUtilCtxt* jniutil;
VTableMgr* vtMgr;
@ -2107,7 +2107,6 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1init
{
jint closure = 0;
JNIGlobalState* state = (JNIGlobalState*)jniGlobalPtr;
map_thread( &state->ti, env );
JNIUtilCtxt* jniutil = makeJNIUtil( MPPARM(state->mpool) env,
&state->ti, jniu );
@ -2116,7 +2115,8 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1init
false );
if ( !!dict ) {
DictIterData* data = XP_CALLOC( state->mpool, sizeof(*data) );
data->state = state;
map_init( MPPARM(state->mpool) &data->ti, env );
map_thread( &data->ti, env );
data->env = env;
data->vtMgr = make_vtablemgr( MPPARM_NOCOMMA(state->mpool) );
data->jniutil = jniutil;
@ -2153,14 +2153,15 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1destroy
#ifdef MEM_DEBUG
MemPoolCtx* mpool = data->mpool;
#endif
JNIGlobalState* state = data->state;
map_thread( &state->ti, env );
map_thread( &data->ti, env );
dict_unref( data->dict );
destroyJNIUtil( env, &data->jniutil );
freeIndices( data );
vtmgr_destroy( MPPARM(mpool) data->vtMgr );
MAP_REMOVE( &data->state->ti, env );
MAP_REMOVE( &data->ti, env );
XP_ASSERT( 0 == countUsed( &data->ti ) );
map_destroy( &data->ti );
XP_FREE( mpool, data );
}
}