Skip to content

Commit

Permalink
add event
Browse files Browse the repository at this point in the history
  • Loading branch information
griffy committed Dec 3, 2011
1 parent 2fcf62c commit 21faf53
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions event.py
@@ -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
4 changes: 2 additions & 2 deletions feq.py
Expand Up @@ -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)
Expand Down

0 comments on commit 21faf53

Please sign in to comment.