base: Add a new type of CallbackQueue.

This type is templated on what arguments the callbacks in it accept, and
it inherits directly from std::list instead of containing one and
forwarding selected members.

This version is called CallbackQueue2, but once all CallbackQueue
instances have been replaced it will be renamed to CallbackQueue.

Issue-on: https://gem5.atlassian.net/browse/GEM5-698
Change-Id: I32ab7454ea8c6a2af31cbcf5d4932a069ace1cb5
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/32642
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2020-08-13 23:27:44 -07:00
parent 96f482fd6c
commit 4f121c11a2

View File

@@ -29,6 +29,7 @@
#ifndef __BASE_CALLBACK_HH__
#define __BASE_CALLBACK_HH__
#include <functional>
#include <list>
#include <string>
@@ -79,6 +80,21 @@ class MakeCallback : public Callback
void process() { (object->*F)(); }
};
class CallbackQueue2 : public std::list<std::function<void()>>
{
public:
using Base = std::list<std::function<void()>>;
using Base::Base;
void
process()
{
for (auto &f: *this)
f();
}
};
class CallbackQueue
{
protected: