dumpHandler = dump_handler;
}
-CallbackQueue dumpQueue;
-CallbackQueue resetQueue;
+CallbackQueue2 dumpQueue;
+CallbackQueue2 resetQueue;
void
processResetQueue()
}
void
-registerResetCallback(Callback *cb)
+registerResetCallback(const std::function<void()> &callback)
{
- resetQueue.add(cb);
+ resetQueue.push_back(callback);
}
bool _enabled = false;
}
void
-registerDumpCallback(Callback *cb)
+registerDumpCallback(const std::function<void()> &callback)
{
- dumpQueue.add(cb);
+ dumpQueue.push_back(callback);
}
} // namespace Stats
#include "base/str.hh"
#include "base/types.hh"
-class Callback;
-
/** The current simulated tick. */
extern Tick curTick();
* Register a callback that should be called whenever statistics are
* reset
*/
-void registerResetCallback(Callback *cb);
+void registerResetCallback(const std::function<void()> &callback);
/**
* Register a callback that should be called whenever statistics are
* about to be dumped
*/
-void registerDumpCallback(Callback *cb);
+void registerDumpCallback(const std::function<void()> &callback);
/**
* Process all the callbacks in the reset callbacks queue
const Loader::SymbolTable &_symtab) :
symtab(_symtab), trace(std::move(_trace))
{
- reset = new MakeCallback<FunctionProfile, &FunctionProfile::clear>(this);
- Stats::registerResetCallback(reset);
-}
-
-FunctionProfile::~FunctionProfile()
-{
- delete reset;
+ Stats::registerResetCallback([this]() { clear(); });
}
ProfileNode *
void clear();
};
-class Callback;
class FunctionProfile
{
private:
friend class ProfileNode;
- Callback *reset = nullptr;
const Loader::SymbolTable &symtab;
ProfileNode top;
std::map<Addr, Counter> pc_count;
public:
FunctionProfile(std::unique_ptr<BaseStackTrace> _trace,
const Loader::SymbolTable &symtab);
- ~FunctionProfile();
ProfileNode *consume(ThreadContext *tc, const StaticInstPtr &inst);
ProfileNode *consume(const std::vector<Addr> &stack);
.flags(nozero | nonan);
// clang-format on
- registerResetCallback(
- new MakeCallback<MemFootprintProbe, &MemFootprintProbe::statReset>(
- this));
+ registerResetCallback([this]() { statReset(); });
}
void
}
// Register a callback function for combining the statistics
- Stats::registerDumpCallback(new StatsCallback(this));
+ Stats::registerDumpCallback([this]() { collateStats(); });
for (auto &it : dynamic_cast<Network *>(this)->params()->ext_links) {
it->params()->ext_node->initNetQueues();
std::vector<bool> m_ordered;
private:
- //! Callback class used for collating statistics from all the
- //! controller of this type.
- class StatsCallback : public Callback
- {
- private:
- Network *ctr;
-
- public:
- virtual ~StatsCallback() {}
-
- StatsCallback(Network *_ctr)
- : ctr(_ctr)
- {
- }
-
- void process() {ctr->collateStats();}
- };
-
// Global address map
struct AddrMapNode {
NodeID id;
if (m_version == 0) {
// Combine the statistics from all controllers
// of this particular type.
- Stats::registerDumpCallback(new StatsCallback(this));
+ Stats::registerDumpCallback([this]() { collateStats(); });
}
}
Stats::Histogram m_delayHistogram;
std::vector<Stats::Histogram *> m_delayVCHistogram;
- //! Callback class used for collating statistics from all the
- //! controller of this type.
- class StatsCallback : public Callback
- {
- private:
- AbstractController *ctr;
-
- public:
- virtual ~StatsCallback() {}
- StatsCallback(AbstractController *_ctr) : ctr(_ctr) {}
- void process() {ctr->collateStats();}
- };
-
/**
* Port that forwards requests and receives responses from the
* memory controller.
m_abstract_controls.resize(MachineType_NUM);
// Collate the statistics before they are printed.
- Stats::registerDumpCallback(new RubyStatsCallback(this));
+ Stats::registerDumpCallback([this]() { collateStats(); });
// Create the profiler
m_profiler = new Profiler(p, this);
m_phys_mem = p->phys_mem;
std::vector<std::map<uint32_t, AbstractController *> > m_abstract_controls;
};
-class RubyStatsCallback : public Callback
-{
- private:
- RubySystem *m_ruby_system;
-
- public:
- virtual ~RubyStatsCallback() {}
- RubyStatsCallback(RubySystem *system) : m_ruby_system(system) {}
- void process() { m_ruby_system->collateStats(); }
-};
-
#endif //__MEM_RUBY_SYSTEM_RUBYSYSTEM_HH__
GlobalEvent *dumpEvent;
-struct SimTicksReset : public Callback
-{
- void process()
- {
- statTime.setTimer();
- startTick = curTick();
- }
-};
-
double
statElapsedTime()
{
return curTick();
}
-SimTicksReset simTicksReset;
-
struct Global
{
Stats::Formula hostInstRate;
hostOpRate = simOps / hostSeconds;
hostTickRate = simTicks / hostSeconds;
- registerResetCallback(&simTicksReset);
+ registerResetCallback([]() {
+ statTime.setTimer();
+ startTick = curTick();
+ });
}
void