Class: Green::Hub::EM::SocketWaiter

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

Defined Under Namespace

Classes: Handler

Instance Attribute Summary

Attributes inherited from SocketWaiter

#socket

Instance Method Summary collapse

Methods inherited from SocketWaiter

#initialize

Constructor Details

This class inherits a constructor from Green::SocketWaiter

Instance Method Details

#make_handler(mode) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/green/hub/em.rb', line 41

def make_handler(mode)
  h = ::EM.watch socket, Handler do |c|
    c.green = Green.current
  end
  case mode
  when :readable
    h.notify_readable = true
  when :writable
    h.notify_writable = true
  end
  Green.hub.switch
ensure
  h.detach
end

#wait_readObject



33
34
35
# File 'lib/green/hub/em.rb', line 33

def wait_read
  make_handler(:readable)
end

#wait_writeObject



37
38
39
# File 'lib/green/hub/em.rb', line 37

def wait_write
  make_handler(:writable)
end