Skip to content

Commit

Permalink
Avoid synchronize { } call only for MRI
Browse files Browse the repository at this point in the history
  • Loading branch information
kamipo committed May 5, 2020
1 parent 776f2ab commit 8b900a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions actionpack/lib/action_dispatch/http/response.rb
Expand Up @@ -215,14 +215,14 @@ def sent!
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.
Expand Down
Expand Up @@ -116,16 +116,16 @@ def any_waiting?
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.
Expand Down Expand Up @@ -826,12 +826,12 @@ def checkout_for_exclusive_access(checkout_timeout)
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
Expand Down

0 comments on commit 8b900a7

Please sign in to comment.