Sha256: df2fb14416efa66c54dc9b0929a0b97602d1ee9731af36cc038b7efc3a12f323

Contents?: true

Size: 745 Bytes

Versions: 20

Compression:

Stored size: 745 Bytes

Contents

module Invoker
  class Reactor
    attr_accessor :reader

    def initialize
      @reader = Invoker::Reactor::Reader.new
    end

    def watch_for_read(fd)
      reader.watch_for_read(fd)
    end

    # Writes data to client socket and raises error if errors
    # while writing
    def send_data(socket, data)
      socket.write(data)
    rescue
      raise Invoker::Errors::ClientDisconnected
    end

    def monitor_for_fd_events
      ready_read_fds, _ , _ = select(*options_for_select)

      if ready_read_fds && !ready_read_fds.empty?
        reader.handle_read_event(ready_read_fds)
      end
    end

    private

    def options_for_select
      [reader.read_array, [], [], 0.05]
    end
  end
end

require "invoker/reactor/reader"

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
itrg-invoker-1.6.1 lib/invoker/reactor.rb
itrg-invoker-1.6.0 lib/invoker/reactor.rb
invoker-1.5.8 lib/invoker/reactor.rb
invoker-1.5.7 lib/invoker/reactor.rb
invoker-1.5.6 lib/invoker/reactor.rb
invoker-1.5.5 lib/invoker/reactor.rb
invoker-1.5.4 lib/invoker/reactor.rb
invoker-1.5.3 lib/invoker/reactor.rb
meepo-1.5.2 lib/invoker/reactor.rb
invoker-1.5.1 lib/invoker/reactor.rb
invoker-1.4.1 lib/invoker/reactor.rb
invoker-1.4.0 lib/invoker/reactor.rb
invoker-1.3.2 lib/invoker/reactor.rb
invoker-1.3.1 lib/invoker/reactor.rb
invoker-1.3.0 lib/invoker/reactor.rb
invoker-1.2.0 lib/invoker/reactor.rb
invoker-1.2.0.pre2 lib/invoker/reactor.rb
invoker-1.2.0.pre1 lib/invoker/reactor.rb
invoker-1.2.0.pre lib/invoker/reactor.rb
invoker-1.1.0 lib/invoker/reactor.rb