Class: Green::Hub::Nio4r::SocketWaiter
- Inherits:
-
SocketWaiter
- Object
- SocketWaiter
- Green::Hub::Nio4r::SocketWaiter
- Defined in:
- lib/green/hub/nio4r.rb
Instance Attribute Summary collapse
-
#reactor ⇒ Object
readonly
Returns the value of attribute reactor.
Attributes inherited from SocketWaiter
Instance Method Summary collapse
-
#initialize(reactor, socket) ⇒ SocketWaiter
constructor
A new instance of SocketWaiter.
- #make_monitor(interest) ⇒ Object
- #wait_read ⇒ Object
- #wait_write ⇒ Object
Constructor Details
#initialize(reactor, socket) ⇒ SocketWaiter
Returns a new instance of SocketWaiter.
6 7 8 9 |
# File 'lib/green/hub/nio4r.rb', line 6 def initialize(reactor, socket) super socket @reactor = reactor end |
Instance Attribute Details
#reactor ⇒ Object (readonly)
Returns the value of attribute reactor.
5 6 7 |
# File 'lib/green/hub/nio4r.rb', line 5 def reactor @reactor end |
Instance Method Details
#make_monitor(interest) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/green/hub/nio4r.rb', line 19 def make_monitor(interest) m = reactor.selector.register(socket, interest) g = Green.current m.value = proc { g.switch } Green.hub.switch ensure reactor.selector.deregister socket end |
#wait_read ⇒ Object
11 12 13 |
# File 'lib/green/hub/nio4r.rb', line 11 def wait_read make_monitor :r end |
#wait_write ⇒ Object
15 16 17 |
# File 'lib/green/hub/nio4r.rb', line 15 def wait_write make_monitor :w end |