Class: Baykit::BayServer::Agent::Multiplexer::TaxiMultiplexer
Defined Under Namespace
Classes: TaxiForMpx
Instance Attribute Summary
#agent, #channel_count, #lock, #rudders, #rudders_lock
Instance Method Summary
collapse
#add_rudder_state, #close_all, #close_rudder, #close_timeout_sockets, #consume_oldest_unit, #find_rudder_state_by_key, #get_rudder_state, #get_transporter, #is_busy, #remove_rudder_state
#add_rudder_state, #close_rudder, #consume_oldest_unit, #get_rudder_state, #get_transporter, #is_busy, #on_busy, #on_free, #remove_rudder_state, #req_end, #shutdown
Constructor Details
Returns a new instance of TaxiMultiplexer.
44
45
46
|
# File 'lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb', line 44
def initialize(agt)
super
end
|
Instance Method Details
#cancel_read(st) ⇒ Object
124
125
126
|
# File 'lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb', line 124
def cancel_read(st)
end
|
#cancel_write(st) ⇒ Object
128
129
130
|
# File 'lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb', line 128
def cancel_write(st)
end
|
#do_next_read(st) ⇒ Object
158
159
160
161
162
163
164
165
166
167
168
169
170
|
# File 'lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb', line 158
def do_next_read(st)
st.access
begin
len = st.rudder.read(st.read_buf, st.buf_size)
if len <= 0
len = 0
end
@agent.send_read_letter(st, len, nil, true)
rescue Exception => e
@agent.send_error_letter(st, e, true)
end
end
|
#do_next_write(st) ⇒ Object
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
# File 'lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb', line 172
def do_next_write(st)
st.access
begin
if st.write_queue.empty?
raise Sink("%s write queue is empty", self)
end
u = st.write_queue[0]
if u.buf.length == 0
len = 0
else
len = st.rudder.write(u.buf)
u.buf.slice!(0, len)
end
@agent.send_wrote_letter(st, len, true)
rescue Exception => e
@agent.send_error_letter(st, e, true)
end
end
|
#is_non_blocking ⇒ Object
144
145
146
|
# File 'lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb', line 144
def is_non_blocking()
return false
end
|
#next_accept(st) ⇒ Object
132
133
134
|
# File 'lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb', line 132
def next_accept(st)
raise Sink.new
end
|
#next_read(st) ⇒ Object
136
137
138
|
# File 'lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb', line 136
def next_read(st)
next_run(st, true)
end
|
#next_run(st, for_read) ⇒ Object
152
153
154
155
156
|
# File 'lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb', line 152
def next_run(st, for_read)
BayLog.debug("%s Post next run: %s", self, st)
TaxiRunner.post(@agent.agent_id, TaxiForMpx.new(st, for_read))
end
|
#next_write(st) ⇒ Object
140
141
142
|
# File 'lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb', line 140
def next_write(st)
next_run(st, false)
end
|
#req_accept(rd) ⇒ Object
56
57
58
|
# File 'lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb', line 56
def req_accept(rd)
raise Sink.new
end
|
#req_close(rd) ⇒ Object
116
117
118
119
120
121
122
|
# File 'lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb', line 116
def req_close(rd)
st = get_rudder_state(rd)
BayLog.debug("%s reqClose st=%s", @agent, st);
close_rudder(st)
@agent.send_closed_letter(st, false)
st.access
end
|
#req_connect(rd, adr) ⇒ Object
60
61
62
|
# File 'lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb', line 60
def req_connect(rd, adr)
raise Sink.new
end
|
#req_read(rd) ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb', line 64
def req_read(rd)
st = get_rudder_state(rd)
if st == nil
return
end
BayLog.debug("%s reqRead rd=%s state=%s", @agent, st.rudder, st);
need_read = false
st.reading_lock.synchronize do
if !st.reading
need_read = true
st.reading = true
end
end
if need_read
next_run(st, true)
end
st.access
end
|
#req_write(rd, buf, adr, tag, &lis) ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb', line 86
def req_write(rd, buf, adr, tag, &lis)
st = get_rudder_state(rd)
BayLog.debug("%s reqWrite st=%s", @agent, st)
if st == nil || st.closed
BayLog.warn("%s Channel is closed: %s", @agent, rd)
lis.call
return
end
unt = WriteUnit.new(buf, adr, tag, &lis)
st.write_queue_lock.synchronize do
st.write_queue << unt
end
need_write = false
st.writing_lock.synchronize do
if !st.writing
need_write = true
st.writing = true
end
end
if need_write
next_run(st, false)
end
st.access
end
|
#to_s ⇒ Object
47
48
49
|
# File 'lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb', line 47
def to_s
return "TaxiMpx[#{@agent}]"
end
|
#use_async_api ⇒ Object
148
149
150
|
# File 'lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb', line 148
def use_async_api()
return false
end
|