Exemplo n.º 1
0
void Thread(void *modName)
{
	asIScriptModule *mod = engine->GetModule((const char *)modName);
	asIScriptFunction *func = mod->GetFunctionByIndex(0);

	asIScriptContext *ctx = engine->CreateContext();

	// Execute the func() script as fast as possible
	while( !stop )
	{
		ctx->Prepare(func);
		ctx->Execute();

		// Sleep a while if there are more than 1000 objects in the GC
		asUINT gcSize;
		engine->GetGCStatistics(&gcSize);
		while( gcSize > 1000 )
		{
			Sleep(10);
			engine->GetGCStatistics(&gcSize);
		}
	}

	ctx->Release();

	// Give AngelScript a chance to cleanup some memory 
	asThreadCleanup();
}
Exemplo n.º 2
0
// interface
int asResetGlobalMemoryFunctions()
{
	asThreadCleanup();

	userAlloc = malloc;
	userFree  = free;

	return 0;
}
Exemplo n.º 3
0
void GCThread(void *)
{
	// Invoke the garbage collector until it is time to stop
	while( !stop )
		engine->GarbageCollect();

	// Give AngelScript a chance to cleanup some memory 
	asThreadCleanup();
}
void Thread(void *)
{
	asIScriptModule *mod = engine->GetModule(0);
	asIScriptFunction *func = mod->GetFunctionDescriptorByIndex(1);
	const char *str = func->GetDeclaration();

	// Give AngelScript a chance to cleanup some memory 
	asThreadCleanup();
}
Exemplo n.º 5
0
// interface
int asResetGlobalMemoryFunctions()
{
	// Clean-up thread local memory before changing the allocation routines to avoid 
	// potential problem with trying to free memory using a different allocation
	// routine than used when allocating it.
	asThreadCleanup();

	userAlloc = malloc;
	userFree  = free;

	return 0;
}
Exemplo n.º 6
0
// interface
int asSetGlobalMemoryFunctions(asALLOCFUNC_t allocFunc, asFREEFUNC_t freeFunc)
{
	// Clean-up thread local memory before changing the allocation routines to avoid 
	// potential problem with trying to free memory using a different allocation
	// routine than used when allocating it.
	asThreadCleanup();

	userAlloc = allocFunc;
	userFree  = freeFunc;

	return 0;
}
Exemplo n.º 7
0
inline void ScriptObject::Invoke(const StringRef& funcName, TArgs&&... args)
{
	asIObjectType* scriptObjectType = mScriptObject->GetObjectType();
	asIScriptFunction* func = scriptObjectType->GetMethodByName(funcName.c_str());
	if (func == nullptr)
	{
		Log::AssertFailedFormat("Cannot find {}::{}", scriptObjectType->GetName(), funcName.c_str());
		return;
	}

	asIScriptContext* context = ScriptEngine::Instance().GetScriptContext();
	context->Prepare(func);
	context->SetObject(mScriptObject);
	SetArgs(context, std::forward<TArgs>(args)...);
	context->Execute();

	asThreadCleanup();
}