Skip to content

Commit 1f82025

Browse files
committed
Fiber.current and Fiber#transfer are available without require 'fiber'
1 parent 847cb7b commit 1f82025

File tree

4 files changed

+5
-18
lines changed

4 files changed

+5
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Compatibility:
8080
* Implement `UnboundMethod#original_name` (@paracycle, @nirvdrum).
8181
* Implement `Thread#native_thread_id` method (#2733, @horakivo).
8282
* Modify `Struct#{inspect,to_s}` to match MRI when the struct is nested inside of an anonymous class or module (@st0012, @nirvdrum).
83+
* `Fiber.current` and `Fiber#transfer` are available without `require 'fiber'` like in CRuby 3.1 (#2733, @eregon).
8384

8485
Performance:
8586

lib/truffle/fiber.rb

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1 @@
1-
# truffleruby_primitives: true
2-
3-
# Copyright (c) 2021, 2023 Oracle and/or its affiliates. All rights reserved. This
4-
# code is released under a tri EPL/GPL/LGPL license. You can use it,
5-
# redistribute it and/or modify it under the terms of the:
6-
#
7-
# Eclipse Public License version 2.0, or
8-
# GNU General Public License version 2, or
9-
# GNU Lesser General Public License version 2.1.
10-
11-
class Fiber
12-
def self.current
13-
Primitive.fiber_current
14-
end
15-
end
1+
# Provided by default

src/main/java/org/truffleruby/core/fiber/FiberNodes.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.truffleruby.annotations.Primitive;
1717
import org.truffleruby.builtins.CoreMethodArrayArgumentsNode;
1818
import org.truffleruby.builtins.PrimitiveArrayArgumentsNode;
19-
import org.truffleruby.builtins.PrimitiveNode;
2019
import org.truffleruby.core.array.RubyArray;
2120
import org.truffleruby.core.cast.SingleValueCastNode;
2221
import org.truffleruby.core.cast.SingleValueCastNodeGen;
@@ -321,8 +320,8 @@ protected boolean alive(RubyFiber fiber) {
321320

322321
}
323322

324-
@Primitive(name = "fiber_current")
325-
public abstract static class CurrentNode extends PrimitiveNode {
323+
@CoreMethod(names = "current", onSingleton = true)
324+
public abstract static class CurrentNode extends CoreMethodArrayArgumentsNode {
326325

327326
@Specialization
328327
protected RubyFiber current() {

src/main/ruby/truffleruby/post-boot/post-boot.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
begin
1515
require 'enumerator'
1616
require 'thread'
17+
require 'fiber'
1718
require 'rational'
1819
require 'complex'
1920
rescue LoadError => e

0 commit comments

Comments
 (0)