summaryrefslogtreecommitdiff
path: root/scheduler.c
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2021-07-19 10:14:51 +1200
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2021-09-20 22:07:58 +1200
commitcb8434563d3cc8fc5c3a5aa1e34ad7a9bb542cdb (patch)
tree8c8aa83cb507d7d1f49199f8c6c554ae00af7a8d /scheduler.c
parent4730a1e0ec24cf273d2d93866ef56f9c5ac2a516 (diff)
Add alternative optional hook for `scheduler_close` to allow public usage of close.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4658
Diffstat (limited to 'scheduler.c')
-rw-r--r--scheduler.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/scheduler.c b/scheduler.c
index ca457b0d14..cd06e55635 100644
--- a/scheduler.c
+++ b/scheduler.c
@@ -13,6 +13,7 @@
#include "ruby/io.h"
static ID id_close;
+static ID id_scheduler_close;
static ID id_block;
static ID id_unblock;
@@ -31,6 +32,7 @@ void
Init_Fiber_Scheduler(void)
{
id_close = rb_intern_const("close");
+ id_scheduler_close = rb_intern_const("scheduler_close");
id_block = rb_intern_const("block");
id_unblock = rb_intern_const("unblock");
@@ -122,9 +124,13 @@ VALUE rb_fiber_scheduler_current_for_thread(VALUE thread)
VALUE
rb_fiber_scheduler_close(VALUE scheduler)
{
- if (rb_respond_to(scheduler, id_close)) {
- return rb_funcall(scheduler, id_close, 0);
- }
+ VALUE result;
+
+ result = rb_check_funcall(scheduler, id_scheduler_close, 0, NULL);
+ if (result != Qundef) return result;
+
+ result = rb_check_funcall(scheduler, id_close, 0, NULL);
+ if (result != Qundef) return result;
return Qnil;
}