From 277980606584473282bbab55de6ddb86dfced978 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Mon, 23 Oct 2023 09:10:58 -0500 Subject: [PATCH] Fiber ext was moved into core in 3.0 --- core/src/main/java/org/jruby/Ruby.java | 1 + .../main/java/org/jruby/ext/fiber/ThreadFiber.java | 8 ++++---- core/src/main/ruby/jruby/kernel/enumerator.rb | 4 ++-- lib/ruby/stdlib/fiber.rb | 12 ------------ 4 files changed, 7 insertions(+), 18 deletions(-) delete mode 100644 lib/ruby/stdlib/fiber.rb diff --git a/core/src/main/java/org/jruby/Ruby.java b/core/src/main/java/org/jruby/Ruby.java index 03dbc4da8dc..f24ecba7807 100644 --- a/core/src/main/java/org/jruby/Ruby.java +++ b/core/src/main/java/org/jruby/Ruby.java @@ -591,6 +591,7 @@ private void initBootLibraries() { loadService.provide("rational.rb"); loadService.provide("complex.rb"); loadService.provide("thread.rb"); + loadService.provide("fiber.rb"); loadService.provide("ruby2_keywords.rb"); // Load preludes diff --git a/core/src/main/java/org/jruby/ext/fiber/ThreadFiber.java b/core/src/main/java/org/jruby/ext/fiber/ThreadFiber.java index f29be1be42a..c676c7dd64b 100644 --- a/core/src/main/java/org/jruby/ext/fiber/ThreadFiber.java +++ b/core/src/main/java/org/jruby/ext/fiber/ThreadFiber.java @@ -305,7 +305,7 @@ private static void handleExceptionDuringExchange(ThreadContext context, FiberDa } @JRubyMethod(rest = true) - public IRubyObject __transfer__(ThreadContext context, IRubyObject[] values) { + public IRubyObject transfer(ThreadContext context, IRubyObject[] values) { Ruby runtime = context.runtime; final FiberData data = this.data; @@ -455,13 +455,13 @@ private static FiberData verifyCurrentFiber(ThreadContext context, Ruby runtime) return currentFiberData; } - @JRubyMethod - public IRubyObject __alive__(ThreadContext context) { + @JRubyMethod(name = "alive?") + public IRubyObject alive_p(ThreadContext context) { return RubyBoolean.newBoolean(context, alive()); } @JRubyMethod(meta = true) - public static IRubyObject __current__(ThreadContext context, IRubyObject recv) { + public static IRubyObject current(ThreadContext context, IRubyObject recv) { return context.getFiber(); } diff --git a/core/src/main/ruby/jruby/kernel/enumerator.rb b/core/src/main/ruby/jruby/kernel/enumerator.rb index cc428d9650f..e9835feee00 100644 --- a/core/src/main/ruby/jruby/kernel/enumerator.rb +++ b/core/src/main/ruby/jruby/kernel/enumerator.rb @@ -98,7 +98,7 @@ def next? end def next - reset unless @fiber&.__alive__ + reset unless @fiber&.alive? val = @fiber.resume @@ -109,7 +109,7 @@ def next def rewind fiber, @fiber = @fiber, nil - fiber.send(:__finalize__) if fiber&.__alive__ + fiber.send(:__finalize__) if fiber&.alive? @state.done = false end diff --git a/lib/ruby/stdlib/fiber.rb b/lib/ruby/stdlib/fiber.rb deleted file mode 100644 index d568fc8e963..00000000000 --- a/lib/ruby/stdlib/fiber.rb +++ /dev/null @@ -1,12 +0,0 @@ -## -# Extensions to Fiber. In JRuby, these are all still defined in the normal -# Fiber class, so we alias them to the right names here. -# -class Fiber - class << self - alias current __current__ - end - - alias transfer __transfer__ - alias alive? __alive__ -end \ No newline at end of file