Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/32642 )

Change subject: base: Add a new type of CallbackQueue.
......................................................................

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
---
M src/base/callback.hh
1 file changed, 18 insertions(+), 0 deletions(-)



diff --git a/src/base/callback.hh b/src/base/callback.hh
index f193361..a02bfba 100644
--- a/src/base/callback.hh
+++ b/src/base/callback.hh
@@ -29,6 +29,7 @@
 #ifndef __BASE_CALLBACK_HH__
 #define __BASE_CALLBACK_HH__

+#include <functional>
 #include <list>
 #include <string>

@@ -79,6 +80,23 @@
     void process() { (object->*F)(); }
 };

+template <typename ...Args>
+class CallbackQueue2 : public std::list<std::function<void(Args...)>>
+{
+  public:
+    using CBFunc = std::function<void(Args...)>;
+    using Base = std::list<CBFunc>;
+
+    using Base::Base;
+
+    void
+    process(Args... args)
+    {
+        for (auto &f: *this)
+            f(args...);
+    }
+};
+
 class CallbackQueue
 {
   protected:

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/32642
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I32ab7454ea8c6a2af31cbcf5d4932a069ace1cb5
Gerrit-Change-Number: 32642
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to