Track the point in the initialization where statistics have been registered.
After this point registering new masterIds can no longer work as some
SimObjects may have sized stats vectors based on the previous value. If someone
tries to register a masterId after this point the simulator executes fatal().
resetQueue.add(cb);
}
+bool _enabled = false;
+
+bool
+enabled()
+{
+ return _enabled;
+}
+
+void
+enable()
+{
+ if (_enabled)
+ fatal("Stats are already enabled");
+
+ _enabled = true;
+}
+
} // namespace Stats
void
/** Dump all statistics data to the registered outputs */
void dump();
void reset();
+void enable();
+bool enabled();
/**
* Register a callback that should be called whenever statistics are
stats_dict[stat.name] = stat
stat.enable()
+ internal.stats.enable();
+
def prepare():
'''Prepare all stats for data access. This must be done before
dumping and serialization.'''
Tick when = curTick(), Tick repeat = 0);
void processResetQueue();
+void enable();
+bool enabled();
std::list<Info *> &statsList();
}
}
- // todo: Check if stats are enabled yet
- // I just don't know a good way to do it
+ // Verify that the statistics haven't been enabled yet
+ // Otherwise objects will have sized their stat buckets and
+ // they will be too small
- if (false)
+ if (Stats::enabled())
fatal("Can't request a masterId after regStats(). \
You must do so in init().\n");