зеркало из https://github.com/github/ruby.git
new benchmark for SizedQueue
The performance of SizedQueue is a bit more complex than regular Queue, so it deserves a separate benchmark. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
5a2c1ee353
Коммит
8e147f1b0d
|
@ -0,0 +1,19 @@
|
|||
require 'thread'
|
||||
|
||||
n = 1_000_000
|
||||
q = Thread::SizedQueue.new(100)
|
||||
consumer = Thread.new{
|
||||
while q.pop
|
||||
# consuming
|
||||
end
|
||||
}
|
||||
|
||||
producer = Thread.new{
|
||||
while n > 0
|
||||
q.push true
|
||||
n -= 1
|
||||
end
|
||||
q.push nil
|
||||
}
|
||||
|
||||
consumer.join
|
Загрузка…
Ссылка в новой задаче