Class: GReactor::ListenerIO
- Defined in:
- lib/greactor/io_wrappers.rb
Overview
a basic Listening IO
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from BasicIO
#cache, #io, #locker, #params, #timeout
Instance Method Summary collapse
- #call ⇒ Object
-
#clear? ⇒ Boolean
ignores timeouts.
-
#initialize(io, params = {}) ⇒ ListenerIO
constructor
A new instance of ListenerIO.
- #on_disconnect ⇒ Object
Methods inherited from BasicIO
#[], #[]=, #close, #closed?, #read, #ssl?, #timeout?, #write
Constructor Details
#initialize(io, params = {}) ⇒ ListenerIO
112 113 114 115 |
# File 'lib/greactor/io_wrappers.rb', line 112 def initialize io, params = {} @io, @params, @locker, @cache = io, params, Mutex.new(), {} GReactor.info "Started Listening on port #{params[:port]}." end |
Instance Method Details
#call ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/greactor/io_wrappers.rb', line 123 def call s = nil begin @locker.synchronize { loop { s = @io.accept_nonblock(); GReactor.add_io s, @params.dup ; s = nil;} } # @locker.synchronize { loop { GReactor.add_io @io.accept_nonblock(), @params.dup } } rescue Errno::EWOULDBLOCK => e rescue => e GReactor.warn "#{e.message} - There are #{GReactor.count_ios} registered open IO objects." ensure (s.close if s && !s.closed? ) rescue true end end |
#clear? ⇒ Boolean
ignores timeouts.
117 118 119 |
# File 'lib/greactor/io_wrappers.rb', line 117 def clear? @io.closed? || (@io.stat.mode < 0140666 ) rescue true end |
#on_disconnect ⇒ Object
120 121 122 |
# File 'lib/greactor/io_wrappers.rb', line 120 def on_disconnect GReactor.info "Stoped Listening to port #{params[:port]}." end |