summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-20 12:26:14 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-20 12:26:14 +0000
commite120cc91f0fedc876e23259ecdb9fb65c71e57dd (patch)
tree440a1259f2547df297909efe4ebd40f5ecf81d51 /thread.c
parent26b9fb4711898189b00ef93183ef9e831f816d63 (diff)
merge revision(s) 57477,57478,57479: [Backport #12405]
use TRUE/FALSE. 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. allow Queue operation in trap. * thread_sync.c: allow spurious wakeup to check Queue status just after trap. [Bug #12405] * test/thread/test_queue.rb: add a test for it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@58036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/thread.c b/thread.c
index 473b6b686c..373dea4d67 100644
--- a/thread.c
+++ b/thread.c
@@ -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_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 rb_thread_sleep_deadly_allow_spurious_wakeup(void);
static double timeofday(void);
static int rb_threadptr_dead(rb_thread_t *th);
static void rb_check_deadlock(rb_vm_t *vm);
@@ -840,7 +841,7 @@ thread_join_sleep(VALUE arg)
while (target_th->status != THREAD_KILLED) {
if (forever) {
- sleep_forever(th, 1, 0);
+ sleep_forever(th, TRUE, FALSE);
}
else {
double now = timeofday();
@@ -1131,14 +1132,21 @@ void
rb_thread_sleep_forever(void)
{
thread_debug("rb_thread_sleep_forever\n");
- sleep_forever(GET_THREAD(), 0, 1);
+ sleep_forever(GET_THREAD(), FALSE, TRUE);
}
void
rb_thread_sleep_deadly(void)
{
thread_debug("rb_thread_sleep_deadly\n");
- sleep_forever(GET_THREAD(), 1, 1);
+ 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