Class: Net::SSH::Compat

Inherits:
Object
  • Object
show all
Defined in:
lib/pmux/mros.rb

Defined Under Namespace

Classes: TimerWatcher, Watcher

Constant Summary collapse

@@loop =
Coolio::Loop.default

Class Method Summary collapse

Class Method Details

.coolio_loopObject



53
54
55
# File 'lib/pmux/mros.rb', line 53

def coolio_loop
  @@loop
end

.coolio_loop=(loop) ⇒ Object



56
57
58
# File 'lib/pmux/mros.rb', line 56

def coolio_loop=(loop)
  @@loop = loop
end

.io_select(reads, writes = nil, excepts = nil, timeout = nil) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/pmux/mros.rb', line 61

def io_select reads, writes=nil, excepts=nil, timeout=nil
  if timeout and timeout.zero?
    io_select0 reads, writes, excepts, 0
  else
    writes ||= []
    loop = @@loop

    watchers = []
    rw = reads & writes
    for io in (reads | writes)
      if rw.include? io
        flag = :rw
      elsif reads.include? io
        flag = :r
      else
        flag = :w
      end
      watcher = Watcher.new io, flag, Fiber.current, watchers
      watchers.push watcher
      watcher.attach loop
    end
    if timeout
      watcher = TimerWatcher.new timeout, Fiber.current, watchers
      watchers.push watcher
      watcher.attach loop
    end
    Fiber.yield
  end
end

.io_select0Object



60
# File 'lib/pmux/mros.rb', line 60

alias :io_select0 :io_select