diff options
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 50 |
1 files changed, 17 insertions, 33 deletions
@@ -9498,9 +9498,7 @@ static int thread_init = 0; # define ruby_signal(x,y) signal((x), (y)) #endif -#if defined(PTHREAD_TIMER) -static pthread_t time_thread; - +#if defined(PTHREAD_TIMER) || defined(HAVE_SETITIMER) static void catch_timer(sig) int sig; @@ -9508,9 +9506,17 @@ catch_timer(sig) #if !defined(POSIX_SIGNAL) && !defined(BSD_SIGNAL) signal(sig, catch_timer); #endif - rb_thread_schedule(); + if (!rb_thread_critical) { + if (rb_trap_immediate) { + rb_thread_schedule(); + } + else rb_thread_pending = 1; + } } +#ifdef PTHREAD_TIMER +static pthread_t time_thread; + static void* thread_timer(dummy) void *dummy; @@ -9518,17 +9524,10 @@ thread_timer(dummy) struct timespec req, rem; for (;;) { - if (!rb_thread_critical) { - if (rb_trap_immediate) { - pthread_kill(ruby_thid, SIGVTALRM); - } - else { - rb_thread_pending = 1; - } - req.tv_sec = 0; - req.tv_nsec = 10000000; - nanosleep(&req, &rem); - } + req.tv_sec = 0; + req.tv_nsec = 10000000; + nanosleep(&req, &rem); + pthread_kill(ruby_thid, SIGVTALRM); } } @@ -9541,23 +9540,7 @@ void rb_thread_stop_timer() { } -#elif defined(HAVE_SETITIMER) - -static void -catch_timer(sig) - int sig; -{ -#if !defined(POSIX_SIGNAL) && !defined(BSD_SIGNAL) - signal(sig, catch_timer); -#endif - if (!rb_thread_critical) { - if (rb_trap_immediate) { - rb_thread_schedule(); - } - else rb_thread_pending = 1; - } -} - +#else /* HAVE_SETITIMER */ void rb_thread_start_timer() { @@ -9581,7 +9564,8 @@ rb_thread_stop_timer() tval.it_value = tval.it_interval; setitimer(ITIMER_VIRTUAL, &tval, NULL); } -#else +#endif +#else /* !(PTHREAD_TIMER || HAVE_SETITIMER) */ int rb_thread_tick = THREAD_TICK; #endif |