Skip to content

Commit 50b3849

Browse files
committed
remove unsafe mutex from configuration
1 parent 4ad4619 commit 50b3849

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

lib/concurrent/configuration.rb

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,6 @@ module Concurrent
99
# An error class to be raised when errors occur during configuration.
1010
ConfigurationError = Class.new(StandardError)
1111

12-
class << self
13-
attr_accessor :configuration
14-
end
15-
16-
# Perform gem-level configuration.
17-
#
18-
# @yield the configuration commands
19-
# @yieldparam [Configuration] the current configuration object
20-
def self.configure
21-
(@mutex ||= Mutex.new).synchronize do
22-
yield(configuration)
23-
24-
# initialize the global thread pools if necessary
25-
configuration.global_task_pool
26-
configuration.global_operation_pool
27-
configuration.global_timer_set
28-
end
29-
end
30-
3112
# A gem-level configuration object.
3213
class Configuration
3314

@@ -120,6 +101,23 @@ def global_operation_pool=(executor)
120101
end
121102
end
122103

104+
# create the default configuration on load
105+
@configuration = Configuration.new
106+
singleton_class.send :attr_reader, :configuration
107+
108+
# Perform gem-level configuration.
109+
#
110+
# @yield the configuration commands
111+
# @yieldparam [Configuration] the current configuration object
112+
def self.configure
113+
yield(configuration)
114+
115+
# initialize the global thread pools if necessary
116+
configuration.global_task_pool
117+
configuration.global_operation_pool
118+
configuration.global_timer_set
119+
end
120+
123121
private
124122

125123
# Attempt to properly shutdown the given executor using the `shutdown` or
@@ -140,8 +138,6 @@ def self.finalize_executor(executor)
140138
false
141139
end
142140

143-
# create the default configuration on load
144-
self.configuration = Configuration.new
145141

146142
# set exit hook to shutdown global thread pools
147143
at_exit do

0 commit comments

Comments
 (0)