Class: Together::Executor

Inherits:
Object
  • Object
show all
Includes:
Mandate
Defined in:
lib/together/executor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mandates, timeout:, raise_exceptions:) ⇒ Executor

 Timeout is in seconds



10
11
12
13
14
15
16
17
18
19
# File 'lib/together/executor.rb', line 10

def initialize(mandates,
               timeout: ,
               raise_exceptions: )
  @mandates = mandates
  @timeout_time = Time.now.to_f + timeout
  @raise_exceptions = raise_exceptions

  @results = Results.new(mandates.size)
  @threads = []
end

Instance Attribute Details

#exceptionsObject (readonly)

Returns the value of attribute exceptions.



5
6
7
# File 'lib/together/executor.rb', line 5

def exceptions
  @exceptions
end

#mandatesObject (readonly)

Returns the value of attribute mandates.



5
6
7
# File 'lib/together/executor.rb', line 5

def mandates
  @mandates
end

#raise_exceptionsObject (readonly)

Returns the value of attribute raise_exceptions.



5
6
7
# File 'lib/together/executor.rb', line 5

def raise_exceptions
  @raise_exceptions
end

#resultsObject (readonly)

Returns the value of attribute results.



5
6
7
# File 'lib/together/executor.rb', line 5

def results
  @results
end

#threadsObject (readonly)

Returns the value of attribute threads.



5
6
7
# File 'lib/together/executor.rb', line 5

def threads
  @threads
end

#timeout_timeObject (readonly)

Returns the value of attribute timeout_time.



5
6
7
# File 'lib/together/executor.rb', line 5

def timeout_time
  @timeout_time
end

Instance Method Details

#callObject



21
22
23
24
25
# File 'lib/together/executor.rb', line 21

def call
  execute_mandates
  wait_for_threads
  results
end