fixed an IO thread termination bug

This commit is contained in:
hyunghwan.chung 2017-12-28 17:10:30 +00:00
parent 09585a4ea5
commit e10f00a1ab
3 changed files with 18 additions and 7 deletions

View File

@ -202,6 +202,7 @@ class MyObject(Object)
while (true)
{
System handleAsyncEvent.
}.
s close dump.

View File

@ -4044,13 +4044,20 @@ static MOO_INLINE int switch_process_if_needed (moo_t* moo)
switch_to_next:
/* TODO: implement different process switching scheme - time-slice or clock based??? */
#if defined(MOO_EXTERNAL_PROCESS_SWITCH)
if (!moo->proc_switched && moo->switch_proc) { switch_to_next_runnable_process (moo); }
moo->switch_proc = 0;
#else
if (!moo->proc_switched) { switch_to_next_runnable_process (moo); }
if (moo->switch_proc)
{
#endif
if (!moo->proc_switched)
{
switch_to_next_runnable_process (moo);
moo->proc_switched = 0;
}
#if defined(MOO_EXTERNAL_PROCESS_SWITCH)
moo->switch_proc = 0;
}
else moo->proc_switched = 0;
#endif
moo->proc_switched = 0;
return 1;
}

View File

@ -1536,6 +1536,8 @@ static void vm_muxwait (moo_t* moo, const moo_ntime_t* dur, moo_vmprim_muxwait_c
}
}
if (xtn->iothr_abort) return;
if (xtn->ev.len <= 0)
{
struct timespec ts;
@ -1908,15 +1910,16 @@ static void setup_tick (void)
struct itimerval itv;
struct sigaction act;
memset (&act, 0, sizeof(act));
sigemptyset (&act.sa_mask);
act.sa_handler = arrange_process_switching;
act.sa_flags = SA_RESTART;
sigaction (SIGVTALRM, &act, MOO_NULL);
itv.it_interval.tv_sec = 0;
itv.it_interval.tv_usec = 100; /* 100 microseconds */
itv.it_interval.tv_usec = 10000; /* microseconds */
itv.it_value.tv_sec = 0;
itv.it_value.tv_usec = 100;
itv.it_value.tv_usec = 10000;
setitimer (ITIMER_VIRTUAL, &itv, MOO_NULL);
#else