summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-25 18:07:08 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-25 18:07:08 +0000
commitd014f463cf6d5dd51aa2ce56385fc08ac5c121af (patch)
tree7d41c2db84af1220161c42569fce993b1b957c21 /thread.c
parented20b2561ce9a387da6de5f93a7b7931cd136efd (diff)
merge revision(s) 57477,57478,57479,57492: [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. test_queue.rb: fix portability * test/thread/test_queue.rb (test_queue_with_trap): fix portability. use SIGINT instead of SIGUSR2 which is supported on not all platforms. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/thread.c b/thread.c
index 046364dfe5..09765e5cad 100644
--- a/thread.c
+++ b/thread.c
@@ -830,7 +830,7 @@ thread_join_sleep(VALUE arg)
while (target_th->status != THREAD_KILLED) {
if (p->forever) {
- sleep_forever(th, 1, 0);
+ sleep_forever(th, TRUE, FALSE);
}
else {
now = timeofday();
@@ -1117,14 +1117,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);
+}
+
+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
@@ -4507,7 +4514,7 @@ rb_mutex_abandon_all(rb_mutex_t *mutexes)
static VALUE
rb_mutex_sleep_forever(VALUE time)
{
- sleep_forever(GET_THREAD(), 1, 0); /* permit spurious check */
+ rb_thread_sleep_deadly_allow_spurious_wakeup();
return Qnil;
}