Skip to content

Commit d199b4c

Browse files
committed
Fix logic for Ractor support
* Fix indentation to stay a multiple of 2 spaces.
1 parent 2ca257f commit d199b4c

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

lib/timeout.rb

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ def self.handle_timeout(message) # :nodoc:
4545

4646
# :stopdoc:
4747

48-
# We keep a private reference so that time mocking libraries won't break
49-
# Timeout.
48+
# We keep a private reference so that time mocking libraries won't break Timeout.
5049
GET_TIME =
5150
if defined?(Ractor.make_shareable)
5251
begin
@@ -71,20 +70,16 @@ def initialize
7170
@timeout_thread_mutex = Mutex.new
7271
end
7372

74-
if defined?(Ractor.store_if_absent) &&
75-
defined?(Ractor.shareable?) && Ractor.shareable?(GET_TIME)
73+
if defined?(Ractor.store_if_absent) && defined?(Ractor.shareable?) && Ractor.shareable?(GET_TIME)
7674

77-
# Ractor support if
78-
# 1. Ractor.store_if_absent is available
79-
# 2. Method object can be shareable (4.0~)
80-
81-
Ractor.store_if_absent :timeout_gem_state do
82-
State.new
83-
end
84-
85-
def self.instance
86-
Ractor[:timeout_gem_state]
87-
end
75+
# Ractor support if
76+
# 1. Ractor.store_if_absent is available
77+
# 2. Method object can be shareable (4.0~)
78+
def self.instance
79+
Ractor.store_if_absent :timeout_gem_state do
80+
State.new
81+
end
82+
end
8883
else
8984
GLOBAL_STATE = State.new
9085

0 commit comments

Comments
 (0)