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.



448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
# File 'lib/em/pure_ruby.rb', line 448

def initialize io
  @uuid = UuidGenerator.generate
  @io = io
  @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
      STDERR.puts "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 (readonly)

Returns the value of attribute io.



446
447
448
# File 'lib/em/pure_ruby.rb', line 446

def io
  @io
end

#uuidObject (readonly)

Returns the value of attribute uuid.



446
447
448
# File 'lib/em/pure_ruby.rb', line 446

def uuid
  @uuid
end

Instance Method Details

#close_scheduled?Boolean

Returns:

  • (Boolean)


475
476
477
# File 'lib/em/pure_ruby.rb', line 475

def close_scheduled?
  @close_scheduled
end

#get_peernameObject



487
488
489
# File 'lib/em/pure_ruby.rb', line 487

def get_peername
  nil
end

#heartbeatObject



495
496
# File 'lib/em/pure_ruby.rb', line 495

def heartbeat
end

#select_for_reading?Boolean

Returns:

  • (Boolean)


479
480
481
# File 'lib/em/pure_ruby.rb', line 479

def select_for_reading?
  false
end

#select_for_writing?Boolean

Returns:

  • (Boolean)


483
484
485
# File 'lib/em/pure_ruby.rb', line 483

def select_for_writing?
  false
end

#set_inactivity_timeout(tm) ⇒ Object



491
492
493
# File 'lib/em/pure_ruby.rb', line 491

def set_inactivity_timeout tm
  @inactivity_timeout = tm
end