Changeset 201

Show
Ignore:
Timestamp:
06/12/06 05:03:43 (2 years ago)
Author:
rosejn
Message:

Added urgent flag so timers can be processed a bit more accurately.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • experiments/EventMachine/ChangeLog

    r200 r201  
    77        determine whether there are more events pending.  This way we don't block on 
    88        select if we can be doing work instead. 
     9 
     10        * Added the urgent flag to EventDispatcher#send_event so events can be put on 
     11        the front of the event queue.  If even more urgency is necessary we can make 
     12        a separate urgent_event_q that gets called more often or before other stuff. 
    913 
    10142006-05-27  Jeff Rose <jeff@rosejn.net> 
  • experiments/EventMachine/lib/machine/event.rb

    r200 r201  
    5858 
    5959    # Send an event to all the handlers for that type. 
    60     def send_event(event) 
    61       @event_q << event 
     60    # Urgent events are put on the front of the queue so they are guaranteed to 
     61    # run the next iteration. 
     62    def send_event(event, urgent = false) 
     63      if urgent 
     64        @event_q.unshift(event) 
     65      else 
     66        @event_q << event 
     67      end 
    6268      log.debug "\tsend_event: #{event.class} (size = #{@event_q.size})" 
    6369    end 
  • experiments/EventMachine/lib/machine/timer.rb

    r200 r201  
    3434        while(not @@timers.empty? and @@timers.first.expiration <= now) 
    3535          timer = @@timers.shift 
    36           timer.send_event(TimerEvent.new) if timer.alive? 
     36          timer.send_event(TimerEvent.new, true) if timer.alive? 
    3737        end 
    3838      end