Skip to content

Commit c93a0b5

Browse files
committed
Emulate blocking fiber in Ruby < 3.2
The patch is mentioned in the following issue: ruby#987 (comment)
1 parent 6e11a7e commit c93a0b5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/debug/thread_client.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -861,16 +861,23 @@ def make_breakpoint args
861861
class SuspendReplay < Exception
862862
end
863863

864+
# Support for ruby 3.2+
864865
if ::Fiber.respond_to?(:blocking)
865866
private def fiber_blocking
866867
::Fiber.blocking{yield}
867868
end
869+
# Support for ruby 3.0+
870+
elsif ::Fiber.respond_to?(:blocking?)
871+
private def fiber_blocking
872+
::Fiber.new(blocking: true) {yield}
873+
end
874+
# Default action for ruby 2.6+
868875
else
869876
private def fiber_blocking
870877
yield
871878
end
872879
end
873-
880+
874881

875882
def wait_next_action
876883
fiber_blocking{wait_next_action_}

0 commit comments

Comments
 (0)