summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2025-12-05 19:25:22 +0100
committergit <svn-admin@ruby-lang.org>2025-12-05 18:32:14 +0000
commit00b91c727fdd0dd3bcd970dd4bc6c2b598cf4e1b (patch)
treed1af3b13cc774039e28c02f3e908372bead77f74
parent3e189ddb9db486d1bc7d5c15f395017b4fb0c136 (diff)
[ruby/timeout] Simplify logic to make GET_TIME shareable
https://github.com/ruby/timeout/commit/281b2507e7
-rw-r--r--lib/timeout.rb15
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/timeout.rb b/lib/timeout.rb
index eab1a1be9e..36cd0f915b 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -46,16 +46,11 @@ module Timeout
# :stopdoc:
# We keep a private reference so that time mocking libraries won't break Timeout.
- GET_TIME =
- if defined?(Ractor.make_shareable)
- begin
- Ractor.make_shareable(Process.method(:clock_gettime))
- rescue # failed on Ruby 3.4
- Process.method(:clock_gettime)
- end
- else
- Process.method(:clock_gettime)
- end
+ GET_TIME = Process.method(:clock_gettime)
+ if defined?(Ractor.make_shareable)
+ # Ractor.make_shareable(Method) only works on Ruby 4+
+ Ractor.make_shareable(GET_TIME) rescue nil
+ end
private_constant :GET_TIME
class State