Don't call Scheduler#close if it doesn't exist.

This commit is contained in:
Samuel Williams 2020-10-01 13:42:58 +13:00
parent bc23216e5a
commit 13660105e2
Notes: git 2020-10-01 12:02:28 +09:00
2 changed files with 11 additions and 1 deletions

View File

@ -39,7 +39,9 @@ Init_Scheduler(void)
VALUE rb_scheduler_close(VALUE scheduler) VALUE rb_scheduler_close(VALUE scheduler)
{ {
return rb_funcall(scheduler, id_close, 0); if (rb_respond_to(scheduler, id_close)) {
return rb_funcall(scheduler, id_close, 0);
}
} }
VALUE VALUE

View File

@ -49,4 +49,12 @@ class TestFiberScheduler < Test::Unit::TestCase
end end
RUBY RUBY
end end
def test_optional_close
thread = Thread.new do
Thread.current.scheduler = Object.new
end
thread.join
end
end end