Sha256: 334947ad1eed7e7707cb58f7e69b5013ec4119477d64ecba833420d1df4b0ebc

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

require 'celluloid/io/version'

require 'celluloid'
require 'celluloid/io/dns_resolver'
require 'celluloid/io/mailbox'
require 'celluloid/io/reactor'
require 'celluloid/io/stream'

require 'celluloid/io/tcp_server'
require 'celluloid/io/tcp_socket'
require 'celluloid/io/udp_socket'
require 'celluloid/io/unix_server'
require 'celluloid/io/unix_socket'

require 'celluloid/io/ssl_server'
require 'celluloid/io/ssl_socket'

module Celluloid
  # Actors with evented IO support
  module IO
    def self.included(klass)
      klass.send :include, Celluloid
      klass.mailbox_class Celluloid::IO::Mailbox
    end

    def self.evented?
      actor = Thread.current[:celluloid_actor]
      actor && actor.mailbox.is_a?(Celluloid::IO::Mailbox)
    end

    def wait_readable(io)
      io = io.to_io
      if IO.evented?
        mailbox = Thread.current[:celluloid_mailbox]
        mailbox.reactor.wait_readable(io)
      else
        Kernel.select([io])
      end
      nil
    end
    module_function :wait_readable

    def wait_writable(io)
      io = io.to_io
      if IO.evented?
        mailbox = Thread.current[:celluloid_mailbox]
        mailbox.reactor.wait_writable(io)
      else
        Kernel.select([], [io])
      end
      nil
    end
    module_function :wait_writable
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
celluloid-io-0.15.0 lib/celluloid/io.rb
celluloid-io-0.15.0.pre2 lib/celluloid/io.rb
celluloid-io-0.15.0.pre lib/celluloid/io.rb
celluloid-io-0.14.1 lib/celluloid/io.rb
celluloid-io-0.14.0 lib/celluloid/io.rb
celluloid-io-0.14.0.pre lib/celluloid/io.rb