Class: CIQuantum::Queue

Inherits:
Object
  • Object
show all
Defined in:
lib/ciquantum/queue.rb

Instance Method Summary collapse

Constructor Details

#initialize(enabled, verbose = false) ⇒ Queue

Returns a new instance of Queue.



3
4
5
6
7
8
9
# File 'lib/ciquantum/queue.rb', line 3

def initialize(enabled, verbose=false)
  @enabled = enabled
  @verbose = verbose
  @queue = []

  log("Build queueing enabled") if enabled
end

Instance Method Details

#append_unless_already_exists(branch) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/ciquantum/queue.rb', line 11

def append_unless_already_exists(branch)
  return unless enabled?
  unless @queue.include? branch
    @queue << branch
    log "#{Time.now.to_i}: Queueing #{branch}"
  end
end

#next_branch_to_buildObject



19
20
21
22
23
# File 'lib/ciquantum/queue.rb', line 19

def next_branch_to_build
  branch = @queue.shift
  log "#{Time.now.to_i}: De-queueing #{branch}"
  branch
end

#waiting?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
# File 'lib/ciquantum/queue.rb', line 25

def waiting?
  if enabled?
    not @queue.empty?
  else
    false
  end
end