Class: Net::SSH::Connection::SingleSessionEventLoop

Inherits:
EventLoop
  • Object
show all
Defined in:
lib/net/ssh/connection/event_loop.rb

Overview

optimized version for a single session

Instance Attribute Summary

Attributes included from Loggable

#logger

Instance Method Summary collapse

Methods inherited from EventLoop

#initialize, #process, #process_only, #register

Methods included from Loggable

#debug, #error, #fatal, #info, #lwarn

Constructor Details

This class inherits a constructor from Net::SSH::Connection::EventLoop

Instance Method Details

#ev_preprocess(&block) ⇒ Object

Compatibility for original single session event loops: we call block with session as argument



101
102
103
104
105
106
107
108
# File 'lib/net/ssh/connection/event_loop.rb', line 101

def ev_preprocess(&block)
  return false if block_given? && !yield(@sessions.first)

  @sessions.each(&:ev_preprocess)
  return false if block_given? && !yield(@sessions.first)

  return true
end

#ev_select_and_postprocess(wait) ⇒ Object



110
111
112
113
114
115
116
117
118
119
# File 'lib/net/ssh/connection/event_loop.rb', line 110

def ev_select_and_postprocess(wait)
  raise "Only one session expected" unless @sessions.count == 1

  session = @sessions.first
  sr, sw, actwait = session.ev_do_calculate_rw_wait(wait)
  readers, writers, = IO.select(sr, sw, nil, actwait)

  session.ev_do_handle_events(readers, writers)
  session.ev_do_postprocess(!((readers.nil? || readers.empty?) && (writers.nil? || writers.empty?)))
end