mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Use a mutex to make SortedSet.setup thread-safe
This should fix [Bug #13735]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
76e3825376
commit
8daa6985dc
1 changed files with 79 additions and 77 deletions
|
@ -634,6 +634,7 @@ end
|
|||
#
|
||||
class SortedSet < Set
|
||||
@@setup = false
|
||||
@@mutex = Mutex.new
|
||||
|
||||
class << self
|
||||
def [](*ary) # :nodoc:
|
||||
|
@ -643,6 +644,7 @@ class SortedSet < Set
|
|||
def setup # :nodoc:
|
||||
@@setup and return
|
||||
|
||||
@@mutex.synchronize do
|
||||
# a hack to shut up warning
|
||||
alias_method :old_init, :initialize
|
||||
|
||||
|
@ -729,13 +731,13 @@ class SortedSet < Set
|
|||
end
|
||||
END
|
||||
end
|
||||
|
||||
# a hack to shut up warning
|
||||
remove_method :old_init
|
||||
|
||||
@@setup = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(*args, &block) # :nodoc:
|
||||
SortedSet.setup
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue