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.



442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
# File 'lib/pr_eventmachine.rb', line 442

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.



440
441
442
# File 'lib/pr_eventmachine.rb', line 440

def io
  @io
end

#uuidObject (readonly)

Returns the value of attribute uuid.



440
441
442
# File 'lib/pr_eventmachine.rb', line 440

def uuid
  @uuid
end

Instance Method Details

#close_scheduled?Boolean

Returns:

  • (Boolean)


469
470
471
# File 'lib/pr_eventmachine.rb', line 469

def close_scheduled?
  @close_scheduled
end

#get_peernameObject



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

def get_peername
  nil
end

#heartbeatObject



489
490
# File 'lib/pr_eventmachine.rb', line 489

def heartbeat
end

#select_for_reading?Boolean

Returns:

  • (Boolean)


473
474
475
# File 'lib/pr_eventmachine.rb', line 473

def select_for_reading?
  false
end

#select_for_writing?Boolean

Returns:

  • (Boolean)


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

def select_for_writing?
  false
end

#set_inactivity_timeout(tm) ⇒ Object



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

def set_inactivity_timeout tm
  @inactivity_timeout = tm
end