From 4f121c11a244097a34f09e7930abbc5123a3c13a Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 13 Aug 2020 23:27:44 -0700 Subject: [PATCH] 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 Maintainer: Gabe Black Tested-by: kokoro --- src/base/callback.hh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/base/callback.hh b/src/base/callback.hh index f1933612a..cef28c32a 100644 --- a/src/base/callback.hh +++ b/src/base/callback.hh @@ -29,6 +29,7 @@ #ifndef __BASE_CALLBACK_HH__ #define __BASE_CALLBACK_HH__ +#include #include #include @@ -79,6 +80,21 @@ class MakeCallback : public Callback void process() { (object->*F)(); } }; +class CallbackQueue2 : public std::list> +{ + public: + using Base = std::list>; + + using Base::Base; + + void + process() + { + for (auto &f: *this) + f(); + } +}; + class CallbackQueue { protected: -- 2.30.2