Skip to content

Commit

Permalink
WIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Nov 8, 2024
1 parent 0b4930d commit c5c7ca9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/async/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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})"
Expand All @@ -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})"
Expand Down

0 comments on commit c5c7ca9

Please sign in to comment.