Class: EventMachine::Selectable

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ Selectable

Returns a new instance of Selectable.



451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
# File 'lib/pr_eventmachine.rb', line 451

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.



449
450
451
# File 'lib/pr_eventmachine.rb', line 449

def io
  @io
end

#uuidObject (readonly)

Returns the value of attribute uuid.



449
450
451
# File 'lib/pr_eventmachine.rb', line 449

def uuid
  @uuid
end

Instance Method Details

#close_scheduled?Boolean

Returns:

  • (Boolean)


478
479
480
# File 'lib/pr_eventmachine.rb', line 478

def close_scheduled?
  @close_scheduled
end

#get_peernameObject



490
491
492
# File 'lib/pr_eventmachine.rb', line 490

def get_peername
  nil
end

#heartbeatObject



498
499
# File 'lib/pr_eventmachine.rb', line 498

def heartbeat
end

#select_for_reading?Boolean

Returns:

  • (Boolean)


482
483
484
# File 'lib/pr_eventmachine.rb', line 482

def select_for_reading?
  false
end

#select_for_writing?Boolean

Returns:

  • (Boolean)


486
487
488
# File 'lib/pr_eventmachine.rb', line 486

def select_for_writing?
  false
end

#set_inactivity_timeout(tm) ⇒ Object



494
495
496
# File 'lib/pr_eventmachine.rb', line 494

def set_inactivity_timeout tm
  @inactivity_timeout = tm
end