asIScriptContext *qasAcquireContext( asIScriptEngine *engine ) { if( !engine ) return NULL; // try to reuse any context linked to this engine qasContextList &ctxList = contexts[engine]; for( qasContextList::iterator it = ctxList.begin(); it != ctxList.end(); it++ ) { asIScriptContext *ctx = *it; if( ctx->GetState() == asEXECUTION_FINISHED ) return ctx; } // if no context was available, create a new one return qasCreateContext( engine ); }
int qasAdquireContext( int engineHandle ) { enginehandle_t *eh = qasGetEngineHandle( engineHandle ); contexthandle_t *ch; if( !eh ) return QASINVALIDHANDLE; // try to reuse any context linked to this engine for( ch = contextHandlesHead; contextHandlesHead != NULL && ch != NULL; ch = ch->next ) { if( ch->owner == engineHandle && ch->ctx->GetState() == asEXECUTION_FINISHED ) return ch->handle; } // if no context was available, create a new one return qasCreateContext( engineHandle ); }