MCPcopy Create free account
hub / github.com/TASEmulators/fceux / emu_exec_time

Function emu_exec_time

src/lua-engine.cpp:5999–6030  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5997}
5998
5999static int emu_exec_time(lua_State *L)
6000{
6001 int count = (int)luaL_checkinteger(L,1);
6002
6003 readyEvent = CreateEvent(0,true,false,0);
6004 goEvent = CreateEvent(0,true,false,0);
6005 DWORD threadid;
6006 HANDLE thread = CreateThread(0,0,emu_exec_time_proc,(LPVOID)L,0,&threadid);
6007 SetThreadAffinityMask(thread,1);
6008 //wait for the lua thread to start
6009 WaitForSingleObject(readyEvent,INFINITE);
6010 ResetEvent(readyEvent);
6011 //tell the lua thread to proceed
6012 SetEvent(goEvent);
6013 //wait for the lua thread to finish, but no more than the specified amount of time
6014 WaitForSingleObject(readyEvent,count);
6015
6016 //kill lua (if it hasnt already been killed)
6017 lua_sethook(L, emu_exec_time_hook, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
6018
6019 //keep on waiting for the lua thread to come back
6020 WaitForSingleObject(readyEvent,count);
6021
6022 //clear the lua thread-killer
6023 lua_sethook(L, NULL, 0, 0);
6024
6025 CloseHandle(readyEvent);
6026 CloseHandle(goEvent);
6027 CloseHandle(thread);
6028
6029 return 1;
6030}
6031
6032#else
6033static int emu_exec_time(lua_State *L) { return 0; }

Callers

nothing calls this directly

Calls 2

luaL_checkintegerFunction · 0.85
lua_sethookFunction · 0.85

Tested by

no test coverage detected