Class: Baykit::BayServer::Agent::NonBlockingHandler
- Inherits:
-
Object
- Object
- Baykit::BayServer::Agent::NonBlockingHandler
- Includes:
- Baykit::BayServer::Agent, TimerHandler, Util
- Defined in:
- lib/baykit/bayserver/agent/non_blocking_handler.rb
Overview
Channel handler
Sockets or file descriptors are kinds of channel
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#ch_count ⇒ Object
readonly
Returns the value of attribute ch_count.
-
#ch_map ⇒ Object
readonly
Returns the value of attribute ch_map.
Instance Method Summary collapse
- #add_channel_listener(ch, lis) ⇒ Object
- #ask_to_close(ch) ⇒ Object
- #ask_to_connect(ch, addr) ⇒ Object
- #ask_to_read(ch) ⇒ Object
- #ask_to_start(ch) ⇒ Object
- #ask_to_write(ch) ⇒ Object
- #close_all ⇒ Object
- #close_timeout_sockets ⇒ Object
-
#initialize(ship_agent) ⇒ NonBlockingHandler
constructor
A new instance of NonBlockingHandler.
-
#on_timer ⇒ Object
Implements TimerHandler.
- #to_s ⇒ Object
Constructor Details
#initialize(ship_agent) ⇒ NonBlockingHandler
Returns a new instance of NonBlockingHandler.
24 25 26 27 28 29 30 31 32 |
# File 'lib/baykit/bayserver/agent/non_blocking_handler.rb', line 24 def initialize(ship_agent) @agent = ship_agent @ch_map = {} @ch_count = 0 @operations = [] @operations_lock = Monitor.new() @agent.add_timer_handler(self) end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
20 21 22 |
# File 'lib/baykit/bayserver/agent/non_blocking_handler.rb', line 20 def agent @agent end |
#ch_count ⇒ Object (readonly)
Returns the value of attribute ch_count.
22 23 24 |
# File 'lib/baykit/bayserver/agent/non_blocking_handler.rb', line 22 def ch_count @ch_count end |
#ch_map ⇒ Object (readonly)
Returns the value of attribute ch_map.
21 22 23 |
# File 'lib/baykit/bayserver/agent/non_blocking_handler.rb', line 21 def ch_map @ch_map end |
Instance Method Details
#add_channel_listener(ch, lis) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/baykit/bayserver/agent/non_blocking_handler.rb', line 56 def add_channel_listener(ch, lis) ch_state = ChannelState.new(ch, lis) add_channel_state(ch, ch_state) ch_state.access() return ch_state end |
#ask_to_close(ch) ⇒ Object
83 84 85 |
# File 'lib/baykit/bayserver/agent/non_blocking_handler.rb', line 83 def ask_to_close(ch) end |
#ask_to_connect(ch, addr) ⇒ Object
71 72 73 |
# File 'lib/baykit/bayserver/agent/non_blocking_handler.rb', line 71 def ask_to_connect(ch, addr) end |
#ask_to_read(ch) ⇒ Object
75 76 77 |
# File 'lib/baykit/bayserver/agent/non_blocking_handler.rb', line 75 def ask_to_read(ch) end |
#ask_to_start(ch) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/baykit/bayserver/agent/non_blocking_handler.rb', line 63 def ask_to_start(ch) BayLog.debug("%s askToStart: ch=%s", @agent, ch) ch_state = find_channel_state(ch) ch_state.accepted = true end |
#ask_to_write(ch) ⇒ Object
79 80 81 |
# File 'lib/baykit/bayserver/agent/non_blocking_handler.rb', line 79 def ask_to_write(ch) end |
#close_all ⇒ Object
87 88 89 90 91 92 |
# File 'lib/baykit/bayserver/agent/non_blocking_handler.rb', line 87 def close_all() @ch_map.keys().each do |ch| st = find_channel_state(ch) close_channel(ch, st) end end |
#close_timeout_sockets ⇒ Object
52 53 54 |
# File 'lib/baykit/bayserver/agent/non_blocking_handler.rb', line 52 def close_timeout_sockets() end |
#on_timer ⇒ Object
Implements TimerHandler
43 44 45 |
# File 'lib/baykit/bayserver/agent/non_blocking_handler.rb', line 43 def on_timer() self.close_timeout_sockets() end |
#to_s ⇒ Object
35 36 37 |
# File 'lib/baykit/bayserver/agent/non_blocking_handler.rb', line 35 def to_s() return @agent.to_s() end |