Class | EventMachine::StreamObject
In: | lib/pr_eventmachine.rb
Parent: | Selectable

### Methods

eventable_read eventable_write get_outbound_data_size get_peername heartbeat new schedule_close select_for_reading? select_for_writing? send_data

### Public Class methods

new(io)

### Public Instance methods

eventable_read()

Proper nonblocking I/O was added to Ruby 1.8.4 in May 2006. If we have it, then we can read multiple times safely to improve performance. The last-activity clock ASSUMES that we only come here when we have selected readable. TODO, coalesce multiple reads into a single event. TODO, do the function check somewhere else and cache it.

eventable_write()

Provisional implementation. Will be re-implemented in subclasses. TODO: Complete this implementation. As it stands, this only writes a single packet per cycle. Highly inefficient, but required unless we‘re running on a Ruby with proper nonblocking I/O (Ruby 1.8.4 built from sources from May 25, 2006 or newer). We need to improve the loop so it writes multiple times, however not more than a certain number of bytes per cycle, otherwise one busy connection could hog output buffers and slow down other connections. Also we should coalesce small writes. URGENT TODO: Coalesce small writes. They are a performance killer. The last-activity recorder ASSUMES we‘ll only come here if we‘ve selected writable.

get_outbound_data_size()

get_outbound_data_size

get_peername()

get_peername This is defined in the normal way on connected stream objects. Return an object that is suitable for passing to Socket#unpack_sockaddr_in or variants. We could also use a convenience method that did the unpacking automatically.

heartbeat()
schedule_close(after_writing)

schedule_close The application wants to close the connection.

select_for_reading?()

If we have to close, or a close-after-writing has been requested, then don‘t read any more data.

select_for_writing?()

If we have to close, don‘t select for writing. Otherwise, see if the protocol is ready to close. If not, see if he has data to send. If a close-after-writing has been requested and the outbound queue is empty, convert the status to close_scheduled.

send_data(data)

send_data

[Validate]