Sha256: c7f274efd20f22c8f7101db2c4639e8e7a028c2bfd216d35832ba9777b5ff7a3

Contents?: true

Size: 562 Bytes

Versions: 3

Compression:

Stored size: 562 Bytes

Contents

# frozen_string_literal: true

require "spec_helper"

RSpec.describe FastlyNsq::PriorityThreadPool do
  let!(:pool) { described_class.new(max_threads: 1) }

  after { pool.shutdown || pool.wait_for_termination }

  it "executes work based on supplied priority" do
    actual = []
    count = 10
    count.times { |i| pool.post(i) { actual << i } }
    expect { pool.completed_task_count }.to eventually(eq(count)).within(30)

    # weak but stable assertion that the last element was not the last processed
    expect(actual.last).not_to eq(count - 1)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fastly_nsq-1.18.1 spec/priority_thread_pool_spec.rb
fastly_nsq-1.18.0 spec/priority_thread_pool_spec.rb
fastly_nsq-1.17.1 spec/priority_thread_pool_spec.rb