Class: Baykit::BayServer::Agent::Multiplexer::SpinMultiplexer::ReadIOLapper

Inherits:
Lapper
  • Object
show all
Defined in:
lib/baykit/bayserver/agent/multiplexer/spin_multiplexer.rb

Instance Attribute Summary collapse

Attributes inherited from Lapper

#last_access, #state

Instance Method Summary collapse

Methods inherited from Lapper

#==, #access

Constructor Details

#initialize(agt, st) ⇒ ReadIOLapper

Returns a new instance of ReadIOLapper.



49
50
51
52
53
# File 'lib/baykit/bayserver/agent/multiplexer/spin_multiplexer.rb', line 49

def initialize(agt, st)
  super(st)
  @agent = agt
  st.rudder.set_non_blocking
end

Instance Attribute Details

#agentObject (readonly)

Returns the value of attribute agent.



47
48
49
# File 'lib/baykit/bayserver/agent/multiplexer/spin_multiplexer.rb', line 47

def agent
  @agent
end

Instance Method Details

#lapObject



55
56
57
58
59
60
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
# File 'lib/baykit/bayserver/agent/multiplexer/spin_multiplexer.rb', line 55

def lap
  spun = false

  begin
    infile = @state.rudder.io
    eof = false

    begin
      n = @state.rudder.read(@state.read_buf, @state.buf_size)
      #infile.sysread(@state.buf_size, @state.read_buf)
    rescue EOFError => e
      @state.read_buf.clear
      eof = true
    rescue Errno::EAGAIN => e
      BayLog.debug("%s %s", @agent, e)
      return true
    end

    if @state.read_buf.length == 0
      if !eof
        return true
      else
        BayLog.debug("%s Spin read: EOF\\(^o^)/ rd=%s", @agent, infile)
      end
    end

    @agent.send_read_letter(@state, @state.read_buf.length, nil, false)
    return false

  rescue Exception => e
    @agent.send_error_letter(@state, e, false)
    return false
  end
end

#nextObject



90
91
92
# File 'lib/baykit/bayserver/agent/multiplexer/spin_multiplexer.rb', line 90

def next

end