Skip to content

Commit a5a8917

Browse files
committed
job_queue: avoid hard-coding limit for long-running jobs
This allows us to keep track of the number of slots in one place instead of two.
1 parent 5ace4e0 commit a5a8917

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/job_queue.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# frozen_string_literal: true
22

3+
require_relative "queue_types"
34
require_relative "shared_state"
45

56
# A variation of `Thread::Queue` that allows us to prioritise certain types of jobs.
@@ -22,8 +23,9 @@ def pop
2223
@mutex.synchronize do
2324
loop do
2425
running_long_build_count = SharedState.instance.running_jobs(@queue_type).count(&:long_build?)
26+
long_build_slots = QueueTypes.slots(@queue_type) / 2
2527

26-
if running_long_build_count < 6 && !@queue[:long].empty?
28+
if running_long_build_count < long_build_slots && !@queue[:long].empty?
2729
break @queue[:long].shift
2830
elsif !@queue[:default].empty?
2931
break @queue[:default].shift

0 commit comments

Comments
 (0)