summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-28 14:40:00 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-28 14:40:00 +0000
commit09f9aa43858de25a16db90fb55dc28a9d7be0e32 (patch)
treefffbd133381c0ec620e351ba17e0c9d8b30e3c16 /thread.c
parente59c7307dabab8dea3dfaea80c02c3155ae10389 (diff)
* thread.c (rb_mutex_sleep): fix to allow spurious wakeup.
* NEWS: write about spurious wakeup. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/thread.c b/thread.c
index 371607b1fa..0b3d009f0a 100644
--- a/thread.c
+++ b/thread.c
@@ -4294,15 +4294,15 @@ rb_mutex_abandon_all(rb_mutex_t *mutexes)
static VALUE
rb_mutex_sleep_forever(VALUE time)
{
- rb_thread_sleep_deadly();
+ sleep_forever(GET_THREAD(), 1, 0); /* permit spurious check */
return Qnil;
}
static VALUE
rb_mutex_wait_for(VALUE time)
{
- const struct timeval *t = (struct timeval *)time;
- rb_thread_wait_for(*t);
+ struct timeval *t = (struct timeval *)time;
+ sleep_timeval(GET_THREAD(), *t, 0); /* permit spurious check */
return Qnil;
}
@@ -4334,6 +4334,9 @@ rb_mutex_sleep(VALUE self, VALUE timeout)
* Releases the lock and sleeps +timeout+ seconds if it is given and
* non-nil or forever. Raises +ThreadError+ if +mutex+ wasn't locked by
* the current thread.
+ *
+ * Note that this method can wakeup without explicit Thread#wakeup call.
+ * For example, receiving signal and so on.
*/
static VALUE
mutex_sleep(int argc, VALUE *argv, VALUE self)