Class: RightSpeed::Processor::AcceptProcessor

Inherits:
Base
  • Object
show all
Defined in:
lib/right_speed/processor.rb

Instance Method Summary collapse

Methods inherited from Base

#process

Constructor Details

#initialize(workers, handler) ⇒ AcceptProcessor

Returns a new instance of AcceptProcessor.



128
129
130
131
132
133
# File 'lib/right_speed/processor.rb', line 128

def initialize(workers, handler)
  @worker_num = workers
  @handler = handler
  @workers = workers.times.map{|i| Worker::Accepter.new(id: i, handler: @handler) }
  @closer = ConnectionCloser.new
end

Instance Method Details

#configure(listener:) ⇒ Object



135
136
137
# File 'lib/right_speed/processor.rb', line 135

def configure(listener:)
  @listener = listener
end

#runObject



139
140
141
142
143
# File 'lib/right_speed/processor.rb', line 139

def run
  @listener.run
  @workers.each{|w| w.run(@listener.sock)}
  @closer.run(@workers.map{|w| w.ractor})
end

#waitObject



145
146
147
148
# File 'lib/right_speed/processor.rb', line 145

def wait
  # workers are using those outgoing to pass connections
  @closer.wait
end