class M2R::MultithreadHandler

Attributes

threads[R]

Public Class Methods

new(singlethread_handler_factory) click to toggle source
# File lib/m2r/multithread_handler.rb, line 6
def initialize(singlethread_handler_factory)
  @singlethread_handler_factory = singlethread_handler_factory
end

Public Instance Methods

listen() click to toggle source
# File lib/m2r/multithread_handler.rb, line 10
def listen
  @threads = 8.times.map do
    Thread.new do
      handler = @singlethread_handler_factory.new
      Thread.current[:m2r_handler] = handler
      handler.listen
    end
  end
end
stop() click to toggle source
# File lib/m2r/multithread_handler.rb, line 20
def stop
  @threads.each do |t|
    t[:m2r_handler].stop
  end
end