Skip to content

Commit

Permalink
Deprecated ActiveRecord::Base.threaded_connection in favor of ActiveR…
Browse files Browse the repository at this point in the history
…ecord::Base.allow_concurrency.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2542 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
Marcel Molina committed Oct 12, 2005
1 parent 0e0e774 commit b840e4e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
2 changes: 2 additions & 0 deletions activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*

* Deprecated ActiveRecord::Base.threaded_connection in favor of ActiveRecord::Base.allow_concurrency.

* Protect id attribute from mass assigment even when the primary key is set to something else. #2438. [Blair Zajac <blair@orcaware.com>]

* Misc doc fixes (typos/grammar/etc.). #2430. [coffee2code]
Expand Down
23 changes: 17 additions & 6 deletions activerecord/lib/active_record/base.rb
Expand Up @@ -235,7 +235,7 @@ class Base
# also be used to "borrow" the connection to do database work unrelated
# to any of the specific Active Records.
def self.connection
if @@threaded_connections
if allow_concurrency
retrieve_connection
else
@connection ||= retrieve_connection
Expand Down Expand Up @@ -301,9 +301,9 @@ def self.reset_subclasses

# Determines whether or not to use a connection for each thread, or a single shared connection for all threads.
# Defaults to true; Railties' WEBrick server sets this to false.
cattr_accessor :threaded_connections
@@threaded_connections = true

cattr_accessor :allow_concurrency
@@allow_concurrency = true
# Determines whether to speed up access by generating optimized reader
# methods to avoid expensive calls to method_missing when accessing
# attributes by name. You might want to set this to false in development
Expand Down Expand Up @@ -787,6 +787,17 @@ def constrain(options = {}, &block)
def ===(object)
object.is_a?(self)
end

# Deprecated
def threaded_connections
allow_concurrency
end

# Deprecated
def threaded_connections=(value)
self.allow_concurrency = value
end


private
# Finder methods must instantiate through this method to work with the single-table inheritance model
Expand Down Expand Up @@ -932,7 +943,7 @@ def subclasses
end

def scope_constraints
if @@threaded_connections
if allow_concurrency
Thread.current[:constraints] ||= {}
Thread.current[:constraints][self] ||= {}
else
Expand All @@ -943,7 +954,7 @@ def scope_constraints
alias_method :scope_constrains, :scope_constraints

def scope_constraints=(value)
if @@threaded_connections
if allow_concurrency
Thread.current[:constraints] ||= {}
Thread.current[:constraints][self] = value
else
Expand Down
Expand Up @@ -62,7 +62,7 @@ def self.establish_connection(spec = nil)
end

def self.active_connections #:nodoc:
if threaded_connections
if allow_concurrency
Thread.current['active_connections'] ||= {}
else
@@active_connections ||= {}
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/threaded_connections_test.rb
Expand Up @@ -12,7 +12,7 @@ def setup
end

def gather_connections(use_threaded_connections)
ActiveRecord::Base.threaded_connections = use_threaded_connections
ActiveRecord::Base.allow_concurrency = use_threaded_connections
ActiveRecord::Base.establish_connection(@connection)

5.times do
Expand Down

0 comments on commit b840e4e

Please sign in to comment.