summaryrefslogtreecommitdiff
path: root/spec/ruby/shared/sizedqueue/num_waiting.rb
blob: 8c31e48ca57f8f9ea3b699c7c1f6125b435efd18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
describe :sizedqueue_num_waiting, shared: true do
  it "reports the number of threads waiting to push" do
    q = @object.call(1)
    q.push(1)
    t = Thread.new { q.push(2) }
    sleep 0.05 until t.stop?
    q.num_waiting.should == 1

    q.pop
    t.join
  end
end