Maintains an ordered list of events, which can be cancelled.
Fire all handles for which Handle#time is less than the given time.
# File lib/timers/events.rb, line 83 def fire(time) pop(time).reverse_each do |handle| handle.fire(time) end end
Returns the first non-cancelled handle.
# File lib/timers/events.rb, line 67 def first while handle = @sequence.last if handle.cancelled? @sequence.pop else return handle end end end
Add an event at the given time.
# File lib/timers/events.rb, line 55 def schedule(time, callback) handle = Handle.new(time.to_f, callback) index = bisect_left(@sequence, handle) # Maintain sorted order, O(logN) insertion time. @sequence.insert(index, handle) return handle end
Generated with the Darkfish Rdoc Generator 2.