Class: EventMachine::Selectable

Inherits:
Object
  • Object
show all
Defined in:
lib/em/pure_ruby.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ Selectable

Returns a new instance of Selectable.



705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
# File 'lib/em/pure_ruby.rb', line 705

def initialize io
  @io = io
  @uuid = UuidGenerator.generate
  @is_server = false
  @last_activity = Reactor.instance.current_loop_time

  if defined?(Fcntl::F_GETFL)
    m = @io.fcntl(Fcntl::F_GETFL, 0)
    @io.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK | m)
  else
    # Windows doesn't define F_GETFL.
    # It's not very reliable about setting descriptors nonblocking either.
    begin
      s = Socket.for_fd(@io.fileno)
      s.fcntl( Fcntl::F_SETFL, Fcntl::O_NONBLOCK )
    rescue Errno::EINVAL, Errno::EBADF
      warn "Serious error: unable to set descriptor non-blocking"
    end
  end
  # TODO, should set CLOEXEC on Unix?

  @close_scheduled = false
  @close_requested = false

  se = self; @io.instance_eval { @my_selectable = se }
  Reactor.instance.add_selectable @io
end

Instance Attribute Details

#ioObject

Returns the value of attribute io.



702
703
704
# File 'lib/em/pure_ruby.rb', line 702

def io
  @io
end

#is_serverObject

Returns the value of attribute is_server.



702
703
704
# File 'lib/em/pure_ruby.rb', line 702

def is_server
  @is_server
end

#uuidObject (readonly)

Returns the value of attribute uuid.



703
704
705
# File 'lib/em/pure_ruby.rb', line 703

def uuid
  @uuid
end

Instance Method Details

#close_scheduled?Boolean

Returns:

  • (Boolean)


733
734
735
# File 'lib/em/pure_ruby.rb', line 733

def close_scheduled?
  @close_scheduled
end

#get_peernameObject



745
746
747
# File 'lib/em/pure_ruby.rb', line 745

def get_peername
  nil
end

#get_socknameObject



749
750
751
# File 'lib/em/pure_ruby.rb', line 749

def get_sockname
  nil
end

#heartbeatObject



757
758
# File 'lib/em/pure_ruby.rb', line 757

def heartbeat
end

#schedule_close(after_writing = false) ⇒ Object



760
761
762
763
764
765
766
# File 'lib/em/pure_ruby.rb', line 760

def schedule_close(after_writing=false)
  if after_writing
    @close_requested = true
  else
    @close_scheduled = true
  end
end

#select_for_reading?Boolean

Returns:

  • (Boolean)


737
738
739
# File 'lib/em/pure_ruby.rb', line 737

def select_for_reading?
  false
end

#select_for_writing?Boolean

Returns:

  • (Boolean)


741
742
743
# File 'lib/em/pure_ruby.rb', line 741

def select_for_writing?
  false
end

#set_inactivity_timeout(tm) ⇒ Object



753
754
755
# File 'lib/em/pure_ruby.rb', line 753

def set_inactivity_timeout tm
  @inactivity_timeout = tm
end