Class: Green::Hub::Nio4r::SocketWaiter

Inherits:
SocketWaiter show all
Defined in:
lib/green/hub/nio4r.rb

Instance Attribute Summary collapse

Attributes inherited from SocketWaiter

#socket

Instance Method Summary collapse

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

#reactorObject (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_readObject



11
12
13
# File 'lib/green/hub/nio4r.rb', line 11

def wait_read
  make_monitor :r
end

#wait_writeObject



15
16
17
# File 'lib/green/hub/nio4r.rb', line 15

def wait_write
  make_monitor :w
end