diff options
author | Samuel Williams <[email protected]> | 2021-02-12 16:54:52 +1300 |
---|---|---|
committer | Samuel Williams <[email protected]> | 2021-03-30 18:38:42 +1300 |
commit | 92449e0e99ae0e44f0deec5e59a7146824872952 (patch) | |
tree | 932ebb123a3ad94d532775f6b4316741130744a2 /cont.c | |
parent | af1c587546c34190721bb8b72e86985e9b79bdc6 (diff) |
Fix handling of timeout accessing scheduler outside of non-blocking context.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4173
Diffstat (limited to 'cont.c')
-rw-r--r-- | cont.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -1997,6 +1997,20 @@ rb_fiber_s_scheduler(VALUE klass) /* * call-seq: + * Fiber.current_scheduler -> obj or nil + * + * Returns the Fiber scheduler, that was last set for the current thread with Fiber.set_scheduler + * iff the current fiber is non-blocking. + * + */ +static VALUE +rb_fiber_current_scheduler(VALUE klass) +{ + return rb_fiber_scheduler_current(); +} + +/* + * call-seq: * Fiber.set_scheduler(scheduler) -> scheduler * * Sets the Fiber scheduler for the current thread. If the scheduler is set, non-blocking @@ -3084,6 +3098,7 @@ Init_Cont(void) rb_define_singleton_method(rb_cFiber, "blocking?", rb_fiber_s_blocking_p, 0); rb_define_singleton_method(rb_cFiber, "scheduler", rb_fiber_s_scheduler, 0); rb_define_singleton_method(rb_cFiber, "set_scheduler", rb_fiber_set_scheduler, 1); + rb_define_singleton_method(rb_cFiber, "current_scheduler", rb_fiber_current_scheduler, 0); rb_define_singleton_method(rb_cFiber, "schedule", rb_fiber_s_schedule, -1); |