define rb_thread_sleep_deadly_allow_spurious_wakeup().

* thread.c, thread_sync.c: define new function
  rb_thread_sleep_deadly_allow_spurious_wakeup() and use it instead of
  using sleep_forever() directly.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2017-01-31 06:39:01 +00:00
parent 919a9d9e02
commit 6897b3b985
2 changed files with 9 additions and 1 deletions

View File

@ -85,6 +85,7 @@ static ID id_locals;
static void sleep_timeval(rb_thread_t *th, struct timeval time, int spurious_check); static void sleep_timeval(rb_thread_t *th, struct timeval time, int spurious_check);
static void sleep_wait_for_interrupt(rb_thread_t *th, double sleepsec, int spurious_check); static void sleep_wait_for_interrupt(rb_thread_t *th, double sleepsec, int spurious_check);
static void sleep_forever(rb_thread_t *th, int nodeadlock, int spurious_check); static void sleep_forever(rb_thread_t *th, int nodeadlock, int spurious_check);
static void rb_thread_sleep_deadly_allow_spurious_wakeup(void);
static double timeofday(void); static double timeofday(void);
static int rb_threadptr_dead(rb_thread_t *th); static int rb_threadptr_dead(rb_thread_t *th);
static void rb_check_deadlock(rb_vm_t *vm); static void rb_check_deadlock(rb_vm_t *vm);
@ -1146,6 +1147,13 @@ rb_thread_sleep_deadly(void)
sleep_forever(GET_THREAD(), TRUE, TRUE); sleep_forever(GET_THREAD(), TRUE, TRUE);
} }
static void
rb_thread_sleep_deadly_allow_spurious_wakeup(void)
{
thread_debug("rb_thread_sleep_deadly_allow_spurious_wakeup\n");
sleep_forever(GET_THREAD(), TRUE, FALSE);
}
static double static double
timeofday(void) timeofday(void)
{ {

View File

@ -420,7 +420,7 @@ rb_mutex_abandon_all(rb_mutex_t *mutexes)
static VALUE static VALUE
rb_mutex_sleep_forever(VALUE time) rb_mutex_sleep_forever(VALUE time)
{ {
sleep_forever(GET_THREAD(), TRUE, FALSE); /* permit spurious check */ rb_thread_sleep_deadly_allow_spurious_wakeup();
return Qnil; return Qnil;
} }