Skip to content

Commit 824f68e

Browse files
authored
Merge pull request #2566 from ksss/fiber-blocking
Add signature for `Fiber#blocking`
2 parents fe043d4 + bc43cdd commit 824f68e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

core/fiber.rbs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ class Fiber < Object
101101
#
102102
def self.[]=: [A] (Symbol, A) -> A
103103

104+
# <!--
105+
# rdoc-file=cont.c
106+
# - Fiber.blocking{|fiber| ...} -> result
107+
# -->
108+
# Forces the fiber to be blocking for the duration of the block. Returns the
109+
# result of the block.
110+
#
111+
# See the "Non-blocking fibers" section in class docs for details.
112+
#
113+
def self.blocking: [T] () { (Fiber) -> T } -> T
114+
104115
# <!--
105116
# rdoc-file=cont.c
106117
# - Fiber.blocking? -> false or 1

test/stdlib/Fiber_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ def test_aref
1717
)
1818
end
1919

20+
def test_blocking
21+
if_ruby("3.2"...) do
22+
assert_send_type "() { (Fiber) -> 42 } -> 42",
23+
Fiber, :blocking do 42 end
24+
end
25+
end
26+
2027
def test_blocking?
2128
assert_send_type "() -> 1",
2229
Fiber, :blocking?

0 commit comments

Comments
 (0)