Class: RightSpeed::Processor::FairProcessor
- Defined in:
- lib/right_speed/processor.rb
Instance Method Summary collapse
- #configure(listener:) ⇒ Object
-
#initialize(workers, handler) ⇒ FairProcessor
constructor
A new instance of FairProcessor.
- #process(conn) ⇒ Object
- #run ⇒ Object
- #wait ⇒ Object
Constructor Details
#initialize(workers, handler) ⇒ FairProcessor
Returns a new instance of FairProcessor.
100 101 102 103 104 105 |
# File 'lib/right_speed/processor.rb', line 100 def initialize(workers, handler) @worker_num = workers @handler = handler @workers = workers.times.map{|i| Worker::Fair.new(id: i, handler: @handler)} @closer = ConnectionCloser.new end |
Instance Method Details
#configure(listener:) ⇒ Object
107 108 109 |
# File 'lib/right_speed/processor.rb', line 107 def configure(listener:) @listener = listener end |
#process(conn) ⇒ Object
117 118 119 |
# File 'lib/right_speed/processor.rb', line 117 def process(conn) Ractor.yield(conn, move: true) end |
#run ⇒ Object
111 112 113 114 115 |
# File 'lib/right_speed/processor.rb', line 111 def run @listener.run(self) @workers.each{|w| w.run(@listener.ractor)} @closer.run(@workers.map{|w| w.ractor}) end |
#wait ⇒ Object
121 122 123 124 |
# File 'lib/right_speed/processor.rb', line 121 def wait # listener, workers are using those outgoing to pass connections @closer.wait end |