ruby-concurrency / concurrent-ruby

Modern concurrency tools including agents, futures, promises, thread pools, supervisors, and more. Inspired by Erlang, Clojure, Scala, Go, Java, JavaScript, and classic concurrency patterns.
https://ruby-concurrency.github.io/concurrent-ruby/
Other
5.71k stars 420 forks source link

Concurrent::Collection::RubyNonConcurrentPriorityQueue#delete works wrong #872

Closed bolshakov closed 3 years ago

bolshakov commented 4 years ago
* Operating system:                mac
* Ruby implementation:             Ruby
* `concurrent-ruby` version:       master

Here is the test case:

def dequeue_all(queue)
  queue.size.times.inject([]) do |acc, _|
    acc << queue.pop
  end
end

queue = described_class.from_list([2, 1, 2, 0, 1, 1, 2], order: :max)

queue.delete(0)

expect(dequeue_all(queue)).to eq([2, 2, 2, 1, 1, 1])

It fails with the following error:

       expected: [2, 2, 2, 1, 1, 1]
            got: [2, 2, 1, 2, 1, 1]

As you can see it does not maintain the oredr after removing an element in some cases.