aboutsummaryrefslogtreecommitdiffstats
path: root/lib/timeout.rb
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-12-26 22:09:49 +1300
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2021-03-30 18:38:42 +1300
commit511acba4aeb3e35cf025a8a6cde4241b7b5167f3 (patch)
tree9944f9cea1fd42e9dc6780bf9ed9dfd6d3090757 /lib/timeout.rb
parent09c865d541472366550804ef09bf14e22a193644 (diff)
downloadruby-511acba4aeb3e35cf025a8a6cde4241b7b5167f3.tar.gz
Update method name and add documentation.
Diffstat (limited to 'lib/timeout.rb')
-rw-r--r--lib/timeout.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/timeout.rb b/lib/timeout.rb
index 9625db77a8..dc8eb24a10 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -73,6 +73,9 @@ module Timeout
# ensure to prevent the handling of the exception. For that reason, this
# method cannot be relied on to enforce timeouts for untrusted blocks.
#
+ # If a scheduler is defined, it will be used to handle the timeout by invoking
+ # Scheduler#timeout_after.
+ #
# Note that this is both a method of module Timeout, so you can <tt>include
# Timeout</tt> into your classes so they have a #timeout method, as well as
# a module method, so you can call it directly as Timeout.timeout().
@@ -81,8 +84,8 @@ module Timeout
message ||= "execution expired".freeze
- if (scheduler = Fiber.scheduler)&.respond_to?(:timeout_raise)
- return scheduler.timeout_raise(sec, klass || Error, message, &block)
+ if (scheduler = Fiber.scheduler)&.respond_to?(:timeout_after)
+ return scheduler.timeout_after(sec, klass || Error, message, &block)
end
from = "from #{caller_locations(1, 1)[0]}" if $DEBUG