Class: Celluloid::IO::TCPServer
- Inherits:
-
Object
- Object
- Celluloid::IO::TCPServer
- Extended by:
- Forwardable
- Defined in:
- lib/celluloid/io/tcp_server.rb
Overview
TCPServer with combined blocking and evented support
Instance Method Summary collapse
- #accept ⇒ Object
- #accept_nonblock ⇒ Object
-
#evented? ⇒ Boolean
Are we inside a Celluloid ::IO actor?.
-
#initialize(hostname, port) ⇒ TCPServer
constructor
A new instance of TCPServer.
- #to_io ⇒ Object
Constructor Details
#initialize(hostname, port) ⇒ TCPServer
Returns a new instance of TCPServer.
10 11 12 |
# File 'lib/celluloid/io/tcp_server.rb', line 10 def initialize(hostname, port) @server = ::TCPServer.new(hostname, port) end |
Instance Method Details
#accept ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/celluloid/io/tcp_server.rb', line 14 def accept actor = Thread.current[:actor] if evented? Celluloid.current_actor.wait_readable @server accept_nonblock else Celluloid::IO::TCPSocket.from_ruby_socket @server.accept end end |
#accept_nonblock ⇒ Object
25 26 27 |
# File 'lib/celluloid/io/tcp_server.rb', line 25 def accept_nonblock Celluloid::IO::TCPSocket.from_ruby_socket @server.accept_nonblock end |
#evented? ⇒ Boolean
Are we inside a Celluloid ::IO actor?
34 35 36 37 |
# File 'lib/celluloid/io/tcp_server.rb', line 34 def evented? actor = Thread.current[:actor] actor && actor.mailbox.is_a?(Celluloid::IO::Mailbox) end |
#to_io ⇒ Object
29 30 31 |
# File 'lib/celluloid/io/tcp_server.rb', line 29 def to_io @server end |