1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Avoid synchronize { } call only for MRI

5e0ef9ca7a
dd1aa73889
ea791e53f9
This commit is contained in:
Ryuta Kamizono 2020-05-05 21:33:23 +09:00
parent 776f2abc5a
commit 8b900a7105
2 changed files with 12 additions and 12 deletions

View file

@ -215,14 +215,14 @@ module ActionDispatch # :nodoc:
end
end
if defined?(JRUBY_VERSION)
def sending?; synchronize { @sending }; end
def committed?; synchronize { @committed }; end
def sent?; synchronize { @sent }; end
else
if RUBY_ENGINE == "ruby"
def sending?; @sending; end
def committed?; @committed; end
def sent?; @sent; end
else
def sending?; synchronize { @sending }; end
def committed?; synchronize { @committed }; end
def sent?; synchronize { @sent }; end
end
# Sets the HTTP status code.

View file

@ -116,16 +116,16 @@ module ActiveRecord
end
end
if defined?(JRUBY_VERSION)
if RUBY_ENGINE == "ruby"
# Returns the number of threads currently waiting on this queue.
attr_reader :num_waiting
else
# Returns the number of threads currently waiting on this queue.
def num_waiting
synchronize do
@num_waiting
end
end
else
# Returns the number of threads currently waiting on this queue.
attr_reader :num_waiting
end
# Add +element+ to the queue. Never blocks.
@ -826,12 +826,12 @@ module ActiveRecord
end
def with_new_connections_blocked
if defined?(JRUBY_VERSION)
if RUBY_ENGINE == "ruby"
@threads_blocking_new_connections += 1
else
synchronize do
@threads_blocking_new_connections += 1
end
else
@threads_blocking_new_connections += 1
end
yield