Skip to content

Commit

Permalink
Add support for Fiber::Scheduler#blocking_operation_wait.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Nov 7, 2024
1 parent 21f9d55 commit 3c8a64f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/async/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,16 @@ def process_wait(pid, flags)
return @selector.process_wait(Fiber.current, pid, flags)
end

def blocking_operation_wait(work)
thread = Thread.new(&work)

thread.join

thread = nil
ensure
thread&.kill
end

# Run one iteration of the event loop.
#
# When terminating the event loop, we already know we are finished. So we don't need to check the task tree. This is a logical requirement because `run_once` ignores transient tasks. For example, a single top level transient task is not enough to keep the reactor running, but during termination we must still process it in order to terminate child tasks.
Expand Down

0 comments on commit 3c8a64f

Please sign in to comment.