Skip to content

Commit

Permalink
Reorganize ruby event_callback to make it clear certain events are ha…
Browse files Browse the repository at this point in the history
…ndled in C
  • Loading branch information
tmm1 committed Mar 8, 2009
1 parent f55ed77 commit 7775e1d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/eventmachine.rb
Expand Up @@ -1250,10 +1250,7 @@ def EventMachine::event_callback conn_binding, opcode, data
# runs down open connections). It should go on the other calls to user
# code, but the performance impact may be too large.
#
if opcode == ConnectionData
c = @conns[conn_binding] or raise ConnectionNotBound, "received data #{data} for unknown signature: #{conn_binding}"
c.receive_data data
elsif opcode == ConnectionUnbound
if opcode == ConnectionUnbound
if c = @conns.delete( conn_binding )
begin
c.unbind
Expand All @@ -1273,12 +1270,17 @@ def EventMachine::event_callback conn_binding, opcode, data
@conns[data] = c
blk and blk.call(c)
c # (needed?)
elsif opcode == TimerFired
t = @timers.delete( data ) or raise UnknownTimerFired, "timer data: #{data}"
t.call
elsif opcode == ConnectionCompleted
c = @conns[conn_binding] or raise ConnectionNotBound, "received ConnectionCompleted for unknown signature: #{conn_binding}"
c.connection_completed
##
# The remaining code is a fallback for the pure ruby reactor. Usually these events are handled in the C event_callback() in rubymain.cpp
elsif opcode == TimerFired
t = @timers.delete( data ) or raise UnknownTimerFired, "timer data: #{data}"
t.call
elsif opcode == ConnectionData
c = @conns[conn_binding] or raise ConnectionNotBound, "received data #{data} for unknown signature: #{conn_binding}"
c.receive_data data
elsif opcode == LoopbreakSignalled
run_deferred_callbacks
elsif opcode == ConnectionNotifyReadable
Expand Down

0 comments on commit 7775e1d

Please sign in to comment.