summaryrefslogtreecommitdiff
path: root/benchmark/bm_vm_thread_queue.rb
blob: 37381ae62b8e28bc31dffb051472df5fd7ba4e06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
require 'thread'

n = 1_000_000
q = Queue.new
consumer = Thread.new{
  while q.pop
    # consuming
  end
}

producer = Thread.new{
  n.times{
    q.push true
  }
  q.push nil
}

consumer.join