Class: Evilution::Parallel::WorkQueue::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/parallel/work_queue/dispatcher.rb

Defined Under Namespace

Classes: RunResult

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workers:, items:, prefetch:, item_timeout:, worker_max_items:, recycle_factory:) ⇒ Dispatcher

Returns a new instance of Dispatcher.



11
12
13
14
15
16
17
18
19
20
# File 'lib/evilution/parallel/work_queue/dispatcher.rb', line 11

def initialize(workers:, items:, prefetch:, item_timeout:, worker_max_items:, recycle_factory:)
  @workers = workers
  @items = items
  @prefetch = prefetch
  @item_timeout = item_timeout
  @worker_max_items = worker_max_items
  @recycle_factory = recycle_factory
  @state = Evilution::Parallel::WorkQueue.send(:const_get, :CollectionState).new(items.length)
  @retired = []
end

Instance Attribute Details

#first_errorObject (readonly)

Returns the value of attribute first_error.



9
10
11
# File 'lib/evilution/parallel/work_queue/dispatcher.rb', line 9

def first_error
  @first_error
end

Instance Method Details

#runObject



22
23
24
25
26
27
# File 'lib/evilution/parallel/work_queue/dispatcher.rb', line 22

def run
  seed
  collect
  @first_error = @state.first_error
  RunResult.new(results: @state.results, retired: @retired)
end