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, #multiplexer, #state, #state_id

Instance Method Summary collapse

Methods inherited from Lapper

#==, #access

Constructor Details

#initialize(mpx, agt, st) ⇒ ReadIOLapper

Returns a new instance of ReadIOLapper.



54
55
56
57
58
# File 'lib/baykit/bayserver/agent/multiplexer/spin_multiplexer.rb', line 54

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

Instance Attribute Details

#agentObject (readonly)

Returns the value of attribute agent.



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

def agent
  @agent
end

Instance Method Details

#lapObject



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
89
90
91
92
# File 'lib/baykit/bayserver/agent/multiplexer/spin_multiplexer.rb', line 60

def lap
  spun = false

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

    begin
      n = @state.rudder.read(@state.read_buf, @state.buf_size)
      if n == 0
        eof = true
      end
    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_id, @state.rudder, @multiplexer, @state.read_buf.length, nil, false)
    return false

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

#nextObject



94
95
96
# File 'lib/baykit/bayserver/agent/multiplexer/spin_multiplexer.rb', line 94

def next

end