Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions core/fiber.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ class Fiber < Object
#
def self.[]=: [A] (Symbol, A) -> A

# <!--
# rdoc-file=cont.c
# - Fiber.blocking{|fiber| ...} -> result
# -->
# Forces the fiber to be blocking for the duration of the block. Returns the
# result of the block.
#
# See the "Non-blocking fibers" section in class docs for details.
#
def self.blocking: [T] () { (Fiber) -> T } -> T

# <!--
# rdoc-file=cont.c
# - Fiber.blocking? -> false or 1
Expand Down
7 changes: 7 additions & 0 deletions test/stdlib/Fiber_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ def test_aref
)
end

def test_blocking
if_ruby("3.2"...) do
assert_send_type "() { (Fiber) -> 42 } -> 42",
Fiber, :blocking do 42 end
end
end

def test_blocking?
assert_send_type "() -> 1",
Fiber, :blocking?
Expand Down