mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 12:34:21 +00:00
[ruby/timeout] Simplify logic to make GET_TIME shareable
https://github.com/ruby/timeout/commit/281b2507e7
This commit is contained in:
parent
3e189ddb9d
commit
00b91c727f
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user