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

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

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.



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

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.



7
8
9
# File 'lib/evilution/parallel/work_queue/dispatcher.rb', line 7

def first_error
  @first_error
end

Instance Method Details

#runObject



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

def run
  seed
  collect
  @first_error = @state.first_error
  [@state.results, @retired]
end