summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'process.c')
-rw-r--r--process.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/process.c b/process.c
index 74301bb..ee5b164 100644
--- a/process.c
+++ b/process.c
@@ -4892,9 +4892,14 @@ rb_f_spawn(int argc, VALUE *argv, VALUE _)
static VALUE
rb_f_sleep(int argc, VALUE *argv, VALUE _)
{
- time_t beg, end;
+ VALUE scheduler = rb_current_thread_scheduler();
- beg = time(0);
+ if (scheduler != Qnil) {
+ VALUE result = rb_funcallv(scheduler, rb_intern("wait_sleep"), argc, argv);
+ return RTEST(result);
+ }
+
+ time_t beg = time(0);
if (argc == 0) {
rb_thread_sleep_forever();
}
@@ -4903,7 +4908,7 @@ rb_f_sleep(int argc, VALUE *argv, VALUE _)
rb_thread_wait_for(rb_time_interval(argv[0]));
}
- end = time(0) - beg;
+ time_t end = time(0) - beg;
return INT2FIX(end);
}