提交 5e0ef9ca 编写于 作者: A Akira Matsuda

No need to synchronize for just reading an ivar, at least in MRI

Monitor `synchronize` became a little bit more costly since https://github.com/ruby/ruby/commit/f91879a7b5 even when then synchronization is nested,
thus we'd better avoid unnecessary `synchronize {  }` call for the majoriry platform that properly implements GVL.
上级 237c8084
......@@ -118,10 +118,16 @@ def any_waiting?
end
end
# Returns the number of threads currently waiting on this
# queue.
def num_waiting
synchronize do
if defined?(JRUBY_VERSION)
# 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.
def num_waiting
@num_waiting
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册