<commit_before># frozen_string_literal: true

require 'spec_helper'

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

  after { pool.shutdown || pool.wait_for_termination }

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

    # weak but stable assertion that the last element was not the last processed
    expect(actual.last).not_to eq(count - 1)
  end
end<commit_msg>test: tweak PriorityThreadPool spec again<commit_after># 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 = 100
    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
{'fraction_non_alphanumeric': 0.10530679933665009, 'fraction_numerical': 0.011608623548922056, 'mean_word_length': 4.0928270042194095, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6794740', 'n_tokens_mistral': 404, 'n_tokens_neox': 373, 'n_words': 107}