sim, arch, base: Refactor the base remote GDB class.
[gem5.git] / src / sim / eventq.cc
index 48664f8e8f06bf4bebbfdf0f766402c2743fb028..80de1808fbef5eb1994c07c3cc3f24d78f110f2e 100644 (file)
 #include <cassert>
 #include <iostream>
 #include <string>
+#include <unordered_map>
 #include <vector>
 
-#include "base/hashmap.hh"
-#include "base/misc.hh"
+#include "base/logging.hh"
 #include "base/trace.hh"
 #include "cpu/smt.hh"
 #include "debug/Checkpoint.hh"
@@ -227,7 +227,7 @@ EventQueue::serviceOne()
 
         event->process();
         if (event->isExitEvent()) {
-            assert(!event->flags.isSet(Event::AutoDelete) ||
+            assert(!event->flags.isSet(Event::Managed) ||
                    !event->flags.isSet(Event::IsMainQueue)); // would be silly
             return event;
         }
@@ -235,8 +235,7 @@ EventQueue::serviceOne()
         event->flags.clear(Event::Squashed);
     }
 
-    if (event->flags.isSet(Event::AutoDelete) && !event->scheduled())
-        delete event;
+    event->release();
 
     return NULL;
 }
@@ -263,9 +262,9 @@ Event::unserialize(CheckpointIn &cp)
 
     // Old checkpoints had no concept of the Initialized flag
     // so restoring from old checkpoints always fail.
-    // Events are initialized on construction but original code 
-    // "flags = _flags" would just overwrite the initialization. 
-    // So, read in the checkpoint flags, but then set the Initialized 
+    // Events are initialized on construction but original code
+    // "flags = _flags" would just overwrite the initialization.
+    // So, read in the checkpoint flags, but then set the Initialized
     // flag on top of it in order to avoid failures.
     assert(initialized());
     flags = _flags;
@@ -282,55 +281,6 @@ Event::unserialize(CheckpointIn &cp)
     }
 }
 
-void
-EventQueue::serialize(CheckpointOut &cp) const
-{
-    std::list<Event *> eventPtrs;
-
-    int numEvents = 0;
-    Event *nextBin = head;
-    while (nextBin) {
-        Event *nextInBin = nextBin;
-
-        while (nextInBin) {
-            if (nextInBin->flags.isSet(Event::AutoSerialize)) {
-                eventPtrs.push_back(nextInBin);
-                paramOut(cp, csprintf("event%d", numEvents++),
-                         nextInBin->name());
-            }
-            nextInBin = nextInBin->nextInBin;
-        }
-
-        nextBin = nextBin->nextBin;
-    }
-
-    SERIALIZE_SCALAR(numEvents);
-
-    for (Event *ev : eventPtrs)
-        ev->serializeSection(cp, ev->name());
-}
-
-void
-EventQueue::unserialize(CheckpointIn &cp)
-{
-    int numEvents;
-    UNSERIALIZE_SCALAR(numEvents);
-
-    std::string eventName;
-    for (int i = 0; i < numEvents; i++) {
-        // get the pointer value associated with the event
-        paramIn(cp, csprintf("event%d", i), eventName);
-
-        // create the event based on its pointer value
-        Serializable *obj(Serializable::create(cp, eventName));
-        Event *event(dynamic_cast<Event *>(obj));
-        fatal_if(!event,
-                 "Event queue unserialized something that wasn't an event.\n");
-
-        checkpointReschedule(event);
-    }
-}
-
 void
 EventQueue::checkpointReschedule(Event *event)
 {
@@ -368,7 +318,7 @@ EventQueue::dump() const
 bool
 EventQueue::debugVerify() const
 {
-    m5::hash_map<long, bool> map;
+    std::unordered_map<long, bool> map;
 
     Tick time = 0;
     short priority = 0;