Class: AWS::Flow::Templates::ResultWorker

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/templates/result.rb

Overview

ResultWorker is responsible for processing the results of the background jobs. It starts an ActivityWorker to process the ActivityTasks for FlowDefaultResultActivityRuby.run activity. It either returns futures or or actual results themselves back to the user

Defined Under Namespace

Classes: SynchronizedHash

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.resultsObject (readonly)

Returns the value of attribute results.



29
30
31
# File 'lib/aws/templates/result.rb', line 29

def results
  @results
end

Class Method Details

.start(domain) ⇒ Object

Starts ResultWorker and ensures that a single ActivityWorker is started for this process. Initializes all class instance variables.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/aws/templates/result.rb', line 38

def self.start(domain)

  # If already initiated, return
  return @task_list if @task_list

  # Acquire the lock to ensure only 1 copy of the worker is created
  @semaphore.synchronize do
    # If multiple threads were waiting on the lock, then we should
    # return if the worker was created by the previous thread
    return @task_list if @task_list
    # Initiate all class instance variables. @semaphore around this
    # block ensures a singleton
    self.init
  end

  # Create pipes for IPC
  reader, writer = IO.pipe

  # Start the ForkingExecutor with the ActivityWorker
  self.start_executor(reader, writer, domain)

  # Close one end of the writer pipe
  writer.close

  # Start the listener thread
  self.start_listener(reader)

  # Register signal handlers for this process
  self.handle_signals

  return @task_list

end