Module: Mycel::Transport::Mixin::Server::Auto

Included in:
AutoServant, AutoServer
Defined in:
lib/mycel.rb

Instance Method Summary collapse

Instance Method Details

#closeObject



224
225
226
227
228
229
230
# File 'lib/mycel.rb', line 224

def close
  @thread_lock.synchronize {
    super
    @thread.join if @thread && @thread != Thread.current
    @thread = nil
  }
end

#initialize(*args, **named_args) ⇒ Object



206
207
208
209
210
# File 'lib/mycel.rb', line 206

def initialize(*args, **named_args)
  super
  @thread = nil
  @thread_lock = Monitor.new   # consistent with the rest of the lib
end

#open(*args, **named_args) ⇒ Object



212
213
214
215
216
217
218
219
220
221
222
# File 'lib/mycel.rb', line 212

def open(*args, **named_args)
  @thread_lock.synchronize {
    super
    @thread = Thread.new {
      begin
        loop { self.connect_this }
      rescue IOError
      end
    }
  }
end