--- a/src/simulator/scheduler-heap.h Tue Dec 12 14:30:44 2006 +0100
+++ b/src/simulator/scheduler-heap.h Tue Dec 12 14:31:16 2006 +0100
@@ -54,8 +54,9 @@
uint32_t Last (void) const;
inline bool IsRoot (uint32_t id) const;
inline bool IsBottom (uint32_t id) const;
- inline bool IsLess (uint32_t a, uint32_t b);
- inline uint32_t Smallest (uint32_t a, uint32_t b);
+ inline bool IsLower (Scheduler::EventKey const*a, Scheduler::EventKey const*b) const;
+ inline bool IsLess (uint32_t a, uint32_t b) const;
+ inline uint32_t Smallest (uint32_t a, uint32_t b) const;
inline void Exch (uint32_t a, uint32_t b);
void BottomUp (void);
--- a/src/simulator/scheduler-list.cc Tue Dec 12 14:30:44 2006 +0100
+++ b/src/simulator/scheduler-list.cc Tue Dec 12 14:31:16 2006 +0100
@@ -31,14 +31,30 @@
SchedulerList::~SchedulerList ()
{}
+bool
+SchedulerList::IsLower (Scheduler::EventKey const*a, Scheduler::EventKey const*b) const
+{
+ if (a->m_ns < b->m_ns)
+ {
+ return true;
+ }
+ else if (a->m_ns == b->m_ns &&
+ a->m_uid < b->m_uid)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
EventId
SchedulerList::RealInsert (EventImpl *event, Scheduler::EventKey key)
{
- Scheduler::EventKeyCompare compare;
for (EventsI i = m_events.begin (); i != m_events.end (); i++)
{
- if (compare (key, i->second))
+ if (IsLower (&key, &i->second))
{
m_events.insert (i, std::make_pair (event, key));
return EventId (event, key.m_ns, key.m_uid);
--- a/src/simulator/scheduler-list.h Tue Dec 12 14:30:44 2006 +0100
+++ b/src/simulator/scheduler-list.h Tue Dec 12 14:31:16 2006 +0100
@@ -46,6 +46,8 @@
virtual EventImpl *RealRemove (EventId ev, Scheduler::EventKey *key);
virtual bool RealIsValid (EventId id);
+ inline bool IsLower (Scheduler::EventKey const*a, Scheduler::EventKey const*b) const;
+
typedef std::list<std::pair<EventImpl*, EventKey> > Events;
typedef std::list<std::pair<EventImpl*, EventKey> >::iterator EventsI;
Events m_events;
--- a/src/simulator/scheduler-map.cc Tue Dec 12 14:30:44 2006 +0100
+++ b/src/simulator/scheduler-map.cc Tue Dec 12 14:31:16 2006 +0100
@@ -43,6 +43,29 @@
SchedulerMap::~SchedulerMap ()
{}
+/* Note the invariants which this function must provide:
+ * - irreflexibility: f (x,x) is false)
+ * - antisymmetry: f(x,y) = !f(y,x)
+ * - transitivity: f(x,y) and f(y,z) => f(x,z)
+ */
+bool
+SchedulerMap::EventKeyCompare::operator () (struct EventKey a, struct EventKey b)
+{
+ if (a.m_ns < b.m_ns)
+ {
+ return true;
+ }
+ else if (a.m_ns == b.m_ns && a.m_uid < b.m_uid)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+
EventId
SchedulerMap::RealInsert (EventImpl *event, Scheduler::EventKey key)
--- a/src/simulator/scheduler-map.h Tue Dec 12 14:30:44 2006 +0100
+++ b/src/simulator/scheduler-map.h Tue Dec 12 14:31:16 2006 +0100
@@ -45,9 +45,15 @@
virtual EventImpl *RealRemove (EventId ev, Scheduler::EventKey *key);
virtual bool RealIsValid (EventId id);
- typedef std::map<Scheduler::EventKey, EventImpl*, Scheduler::EventKeyCompare> EventMap;
- typedef std::map<Scheduler::EventKey, EventImpl*, Scheduler::EventKeyCompare>::iterator EventMapI;
- typedef std::map<Scheduler::EventKey, EventImpl*, Scheduler::EventKeyCompare>::const_iterator EventMapCI;
+ class EventKeyCompare {
+ public:
+ bool operator () (struct EventKey a, struct EventKey b);
+ };
+
+ typedef std::map<Scheduler::EventKey, EventImpl*, SchedulerMap::EventKeyCompare> EventMap;
+ typedef std::map<Scheduler::EventKey, EventImpl*, SchedulerMap::EventKeyCompare>::iterator EventMapI;
+ typedef std::map<Scheduler::EventKey, EventImpl*, SchedulerMap::EventKeyCompare>::const_iterator EventMapCI;
+
EventMap m_list;
uint32_t m_uid;
--- a/src/simulator/scheduler.cc Tue Dec 12 14:30:44 2006 +0100
+++ b/src/simulator/scheduler.cc Tue Dec 12 14:31:16 2006 +0100
@@ -27,29 +27,6 @@
Scheduler::~Scheduler ()
{}
-/* Note the invariants which this function must provide:
- * - irreflexibility: f (x,x) is false)
- * - antisymmetry: f(x,y) = !f(y,x)
- * - transitivity: f(x,y) and f(y,z) => f(x,z)
- */
-bool
-Scheduler::EventKeyCompare::operator () (struct EventKey a, struct EventKey b)
-{
- if (a.m_ns < b.m_ns)
- {
- return true;
- }
- else if (a.m_ns == b.m_ns && a.m_uid < b.m_uid)
- {
- return true;
- }
- else
- {
- return false;
- }
-}
-
-
EventId
Scheduler::Insert (EventImpl *event, struct EventKey key)
{
--- a/src/simulator/scheduler.h Tue Dec 12 14:30:44 2006 +0100
+++ b/src/simulator/scheduler.h Tue Dec 12 14:31:16 2006 +0100
@@ -58,10 +58,6 @@
uint64_t m_ns;
uint32_t m_uid;
};
- class EventKeyCompare {
- public:
- bool operator () (struct EventKey a, struct EventKey b);
- };
virtual ~Scheduler () = 0;