summaryrefslogtreecommitdiff
path: root/src/base/coroutine.test.cc
diff options
context:
space:
mode:
authorMichiel W. van Tol <Michiel.VanTol@arm.com>2018-08-31 12:50:20 +0100
committerGiacomo Travaglini <giacomo.travaglini@arm.com>2019-06-28 08:25:20 +0000
commit08e7849f2710e6b62aa07db86e356edb15a99f9c (patch)
tree0c8a11a85ad57db68198072b89519e403a1168c9 /src/base/coroutine.test.cc
parentcb2be9940a055bf73647e9eef3779992d5af36b7 (diff)
downloadgem5-08e7849f2710e6b62aa07db86e356edb15a99f9c.tar.xz
base: Add argument to Coroutine class to not run on creation
In some cases, the point where you create a Coroutine is not the same as where you want to start running it (and want it to switch back to). This leads to the unnecessary overhead of switching in and out of the Coroutine. This change adds an optional boolean argument to the constructor for the Coroutine class to allow for overriding the default behavior of running the Coroutine upon creation, which in specific cases can be used to avoid the unnecessary overhead and improve simulator performance. Change-Id: I044698f85e81ee4144208aee30d133bcb462d35d Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18588 Reviewed-by: Anthony Gutierrez <anthony.gutierrez@amd.com> Maintainer: Anthony Gutierrez <anthony.gutierrez@amd.com> Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'src/base/coroutine.test.cc')
-rw-r--r--src/base/coroutine.test.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/base/coroutine.test.cc b/src/base/coroutine.test.cc
index 655bc254a..586686972 100644
--- a/src/base/coroutine.test.cc
+++ b/src/base/coroutine.test.cc
@@ -44,6 +44,25 @@
using namespace m5;
/**
+ * This test is checking if the Coroutine, once it's created
+ * it doesn't start since the second argument of the constructor
+ * (run_coroutine) is set to false
+ */
+TEST(Coroutine, Unstarted)
+{
+ auto yielding_task =
+ [] (Coroutine<void, void>::CallerType& yield)
+ {
+ yield();
+ };
+
+ const bool start_upon_creation = false;
+ Coroutine<void, void> coro(yielding_task, start_upon_creation);
+
+ ASSERT_FALSE(coro.started());
+}
+
+/**
* This test is checking if the Coroutine, once it yields
* back to the caller, it is still marked as not finished.
*/