Class: Pione::DRbPatch::PioneDRbServer

Inherits:
DRb::DRbServer
  • Object
show all
Defined in:
lib/pione/patch/drb-patch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri = nil, front = nil, config_or_acl = nil) ⇒ PioneDRbServer

Returns a new instance of PioneDRbServer.



468
469
470
471
472
473
# File 'lib/pione/patch/drb-patch.rb', line 468

def initialize(uri=nil, front=nil, config_or_acl=nil)
  # current performing invokers
  @invoker_threads = ThreadGroup.new

  super
end

Instance Attribute Details

#invoker_threadsObject (readonly)

Returns the value of attribute invoker_threads.



466
467
468
# File 'lib/pione/patch/drb-patch.rb', line 466

def invoker_threads
  @invoker_threads
end

Instance Method Details

#main_loopObject



475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
# File 'lib/pione/patch/drb-patch.rb', line 475

def main_loop
  if @protocol.uri =~ /^receiver:/
    RequestLooper.start(self, @protocol)
    @thread.kill.join # stop transceiver
  else
    Thread.start(@protocol.accept) do |client|
      # relay socket doesn't need request receiver loop because its aim is
      # to get connection only
      unless @protocol.kind_of?(Pione::Relay::RelaySocket)
        # set DRb info to current thread
        Thread.current['DRb'] = {'client' => client, 'server' => self}

        # add exported uri
        DRb.mutex.synchronize do
          client_uri = client.uri
          @exported_uri << client_uri unless @exported_uri.include?(client_uri)
        end

        # start request loop
        RequestLooper.new(self).start(client)
      end
    end
  end

  def stop_service
    # stop invokers
    @invoker_threads.list.each {|thread| thread.kill.join}

    # stop main loop etc.
    super
  end
end

#stop_serviceObject



499
500
501
502
503
504
505
# File 'lib/pione/patch/drb-patch.rb', line 499

def stop_service
  # stop invokers
  @invoker_threads.list.each {|thread| thread.kill.join}

  # stop main loop etc.
  super
end