Permalink
Browse files

add event

  • Loading branch information...
1 parent 2fcf62c commit 21faf53021157c05c00cb1fef78664bedd72aced @griffy committed Dec 3, 2011
Showing with 9 additions and 2 deletions.
  1. +7 −0 event.py
  2. +2 −2 feq.py
View
@@ -0,0 +1,7 @@
+class Event(object):
+ # keep a (static) class variable to keep track of total events
+ count = 0
+ def __init__(self, time):
+ self.time = time
+ self.id = Event.count
+ Event.count += 1
View
4 feq.py
@@ -8,9 +8,9 @@ def schedule_event(self, event):
# in case we have two events scheduled to happen at the same time
# and we want/need one to happen before the other, we schedule
# first according to the time and second according to the number
- # of the event
+ # of the event (ie, event #1 before event #2)
heapq.heappush(self._priority_queue,
- ((event.time, event.count), event))
+ ((event.time, event.id), event))
def next_event(self):
event_tuple = heapq.heappop(self._priority_queue)

0 comments on commit 21faf53

Please sign in to comment.