Class: DRb::DRbServer
- Inherits:
-
Object
- Object
- DRb::DRbServer
- Defined in:
- lib/emdrb/emdrb.rb
Overview
Class representing a drb server instance. DRbServer instances are normally created indirectly using either DRb.start_service or EMDRb.start_drbserver (designed to be called from within an event loop).
Instance Method Summary collapse
-
#initialize(uri = nil, front = nil, config_or_acl = nil) ⇒ DRbServer
constructor
A new instance of DRbServer.
-
#start_drb_server ⇒ Object
Start a DRb server from within an event loop.
-
#stop_service ⇒ Object
Stop this server.
Constructor Details
#initialize(uri = nil, front = nil, config_or_acl = nil) ⇒ DRbServer
Returns a new instance of DRbServer.
652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 |
# File 'lib/emdrb/emdrb.rb', line 652 def initialize(uri=nil, front=nil, config_or_acl=nil) if Hash === config_or_acl config = config_or_acl.dup else acl = config_or_acl || @@acl config = { :tcp_acl => acl } end @config = self.class.make_config(config) @protocol = DRbTransport.factory(uri, config) @front = front @idconv = @config[:idconv] @safe_level = @config[:safe_level] EventMachine::next_tick do @thread = Thread.current end end |
Instance Method Details
#start_drb_server ⇒ Object
Start a DRb server from within an event loop.
675 676 677 678 679 680 681 682 683 684 685 686 687 |
# File 'lib/emdrb/emdrb.rb', line 675 def start_drb_server @thread = Thread.current @protocol.start_server(DRbServerProtocol) do |conn| Thread.current['DRb'] = { 'client' => conn, 'server' => self } conn.front = @front conn.load_limit = @config[:load_limit] conn.argc_limit = @config[:argc_limit] conn.idconv = @config[:idconv] conn.server = self conn.safe_level = self.safe_level end @uri = @protocol.uri end |
#stop_service ⇒ Object
Stop this server.
691 692 693 694 695 696 697 698 699 |
# File 'lib/emdrb/emdrb.rb', line 691 def stop_service DRb.remove_server(self) if Thread.current['DRb'] && Thread.current['DRb']['server'] == self Thread.current['DRb']['stop_service'] = true else @thread.kill end @protocol.stop_server end |