summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2010-03-12 17:31:04 -0800
committerNathan Binkert <nate@binkert.org>2010-03-12 17:31:04 -0800
commit671faf33168595590b123d96d0a7223c5c053310 (patch)
tree85cd8a934f31dc0a6829d9e5ec53e430f30f0107 /src/sim
parent402f42ebfa1ac68062f8fd8030e432d982ea1f8d (diff)
downloadgem5-671faf33168595590b123d96d0a7223c5c053310.tar.xz
eventq: rearrange a little bit so I can add some stuff
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/eventq.hh154
1 files changed, 78 insertions, 76 deletions
diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh
index 90dd5b4b9..d9ca02768 100644
--- a/src/sim/eventq.hh
+++ b/src/sim/eventq.hh
@@ -311,6 +311,47 @@ class Event : public Serializable, public FastAlloc
#endif
};
+#ifndef SWIG
+inline bool
+operator<(const Event &l, const Event &r)
+{
+ return l.when() < r.when() ||
+ (l.when() == r.when() && l.priority() < r.priority());
+}
+
+inline bool
+operator>(const Event &l, const Event &r)
+{
+ return l.when() > r.when() ||
+ (l.when() == r.when() && l.priority() > r.priority());
+}
+
+inline bool
+operator<=(const Event &l, const Event &r)
+{
+ return l.when() < r.when() ||
+ (l.when() == r.when() && l.priority() <= r.priority());
+}
+inline bool
+operator>=(const Event &l, const Event &r)
+{
+ return l.when() > r.when() ||
+ (l.when() == r.when() && l.priority() >= r.priority());
+}
+
+inline bool
+operator==(const Event &l, const Event &r)
+{
+ return l.when() == r.when() && l.priority() == r.priority();
+}
+
+inline bool
+operator!=(const Event &l, const Event &r)
+{
+ return l.when() != r.when() || l.priority() != r.priority();
+}
+#endif
+
/*
* Queue of events sorted in time order
*/
@@ -430,51 +471,6 @@ class EventManager
}
};
-template <class T, void (T::* F)()>
-void
-DelayFunction(EventQueue *eventq, Tick when, T *object)
-{
- class DelayEvent : public Event
- {
- private:
- T *object;
-
- public:
- DelayEvent(T *o)
- : object(o)
- { this->setFlags(AutoDelete); }
- void process() { (object->*F)(); }
- const char *description() const { return "delay"; }
- };
-
- eventq->schedule(new DelayEvent(object), when);
-}
-
-template <class T, void (T::* F)()>
-class EventWrapper : public Event
-{
- private:
- T *object;
-
- public:
- EventWrapper(T *obj, bool del = false, Priority p = Default_Pri)
- : Event(p), object(obj)
- {
- if (del)
- setFlags(AutoDelete);
- }
-
- void process() { (object->*F)(); }
-
- const std::string
- name() const
- {
- return object->name() + ".wrapped_event";
- }
-
- const char *description() const { return "EventWrapped"; }
-};
-
inline void
EventQueue::schedule(Event *event, Tick when)
{
@@ -541,44 +537,50 @@ EventQueue::reschedule(Event *event, Tick when, bool always)
event->trace("rescheduled");
}
-inline bool
-operator<(const Event &l, const Event &r)
+template <class T, void (T::* F)()>
+void
+DelayFunction(EventQueue *eventq, Tick when, T *object)
{
- return l.when() < r.when() ||
- (l.when() == r.when() && l.priority() < r.priority());
-}
+ class DelayEvent : public Event
+ {
+ private:
+ T *object;
-inline bool
-operator>(const Event &l, const Event &r)
-{
- return l.when() > r.when() ||
- (l.when() == r.when() && l.priority() > r.priority());
-}
+ public:
+ DelayEvent(T *o)
+ : object(o)
+ { this->setFlags(AutoDelete); }
+ void process() { (object->*F)(); }
+ const char *description() const { return "delay"; }
+ };
-inline bool
-operator<=(const Event &l, const Event &r)
-{
- return l.when() < r.when() ||
- (l.when() == r.when() && l.priority() <= r.priority());
-}
-inline bool
-operator>=(const Event &l, const Event &r)
-{
- return l.when() > r.when() ||
- (l.when() == r.when() && l.priority() >= r.priority());
+ eventq->schedule(new DelayEvent(object), when);
}
-inline bool
-operator==(const Event &l, const Event &r)
+template <class T, void (T::* F)()>
+class EventWrapper : public Event
{
- return l.when() == r.when() && l.priority() == r.priority();
-}
+ private:
+ T *object;
-inline bool
-operator!=(const Event &l, const Event &r)
-{
- return l.when() != r.when() || l.priority() != r.priority();
-}
+ public:
+ EventWrapper(T *obj, bool del = false, Priority p = Default_Pri)
+ : Event(p), object(obj)
+ {
+ if (del)
+ setFlags(AutoDelete);
+ }
+
+ void process() { (object->*F)(); }
+
+ const std::string
+ name() const
+ {
+ return object->name() + ".wrapped_event";
+ }
+
+ const char *description() const { return "EventWrapped"; }
+};
#endif
#endif // __SIM_EVENTQ_HH__