From c5c7ca93b5bb9a4ea9615eaa6129f8f7637dc3f1 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 8 Nov 2024 21:58:46 +1300 Subject: [PATCH] WIP. --- lib/async/scheduler.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/async/scheduler.rb b/lib/async/scheduler.rb index b6aba79..350ed93 100644 --- a/lib/async/scheduler.rb +++ b/lib/async/scheduler.rb @@ -75,6 +75,8 @@ def load # Invoked when the fiber scheduler is being closed. # # Executes the run loop until all tasks are finished, then closes the scheduler. + # + # Introduced in Ruby v3.1. def scheduler_close(error = $!) # If the execution context (thread) was handling an exception, we want to exit as quickly as possible: unless error @@ -167,6 +169,9 @@ def resume(fiber, *arguments) end # Invoked when a fiber tries to perform a blocking operation which cannot continue. A corresponding call {unblock} must be performed to allow this fiber to continue. + # + # Introduced in Ruby v3.1. + # # @asynchronous May only be called on same thread as fiber scheduler. def block(blocker, timeout) # $stderr.puts "block(#{blocker}, #{Fiber.current}, #{timeout})" @@ -190,6 +195,10 @@ def block(blocker, timeout) timer&.cancel! end + # Unblock a fiber that was previously blocked. + # + # Introduced in Ruby v3.1. + # # @asynchronous May be called from any thread. def unblock(blocker, fiber) # $stderr.puts "unblock(#{blocker}, #{fiber})"