Skip to content

Commit

Permalink
Put mutex at class level
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Nov 14, 2012
1 parent 4f74ce6 commit 6f54b85
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions lib/mongoid/config.rb
Expand Up @@ -13,6 +13,8 @@ module Config
extend Options
include ActiveModel::Observing

LOCK = Mutex.new

option :allow_dynamic_fields, default: true
option :identity_map_enabled, default: false
option :include_root_in_json, default: false
Expand Down Expand Up @@ -108,7 +110,7 @@ def models
#
# @since 3.1.0
def register_model(klass)
lock.synchronize do
LOCK.synchronize do
models.push(klass) unless models.include?(klass)
end
end
Expand Down Expand Up @@ -255,22 +257,5 @@ def time_zone
def running_with_passenger?
@running_with_passenger ||= defined?(PhusionPassenger)
end

private

# Gets the mutex for synchronizing methods on the configuration.
#
# @api private
#
# @example Get the mutex.
# config.lock
#
# @return [ Mutex ] The mutex.
#
# @since 3.1.0
def lock
@mutex ||= Mutex.new
end

end
end

0 comments on commit 6f54b85

Please sign in to comment.