#197 wait 1 sec before exit infinite loop
This commit is contained in:
parent
329a6bad0b
commit
ea362a12e0
13
src/jsapi.c
13
src/jsapi.c
|
@ -821,18 +821,29 @@ static const struct{duk_c_function func; s32 params;} ApiFunc[] =
|
||||||
|
|
||||||
STATIC_ASSERT(api_func, COUNT_OF(ApiKeywords) == COUNT_OF(ApiFunc));
|
STATIC_ASSERT(api_func, COUNT_OF(ApiKeywords) == COUNT_OF(ApiFunc));
|
||||||
|
|
||||||
|
static u64 ForceExitCounter = 0;
|
||||||
|
|
||||||
s32 duk_timeout_check(void* udata)
|
s32 duk_timeout_check(void* udata)
|
||||||
{
|
{
|
||||||
tic_machine* machine = (tic_machine*)udata;
|
tic_machine* machine = (tic_machine*)udata;
|
||||||
tic_tick_data* tick = machine->data;
|
tic_tick_data* tick = machine->data;
|
||||||
|
|
||||||
return tick->forceExit && tick->forceExit(tick->data);
|
enum{Wait = 1000}; // 1 sec
|
||||||
|
|
||||||
|
if(ForceExitCounter)
|
||||||
|
return ForceExitCounter < tick->counter();
|
||||||
|
else if(tick->forceExit && tick->forceExit(tick->data))
|
||||||
|
ForceExitCounter = tick->counter() + Wait * 1000 / tick->freq();
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initDuktape(tic_machine* machine)
|
static void initDuktape(tic_machine* machine)
|
||||||
{
|
{
|
||||||
closeJavascript((tic_mem*)machine);
|
closeJavascript((tic_mem*)machine);
|
||||||
|
|
||||||
|
ForceExitCounter = 0;
|
||||||
|
|
||||||
duk_context* duk = machine->js = duk_create_heap(NULL, NULL, NULL, machine, NULL);
|
duk_context* duk = machine->js = duk_create_heap(NULL, NULL, NULL, machine, NULL);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue