summaryrefslogtreecommitdiff
path: root/indra/test/lltestapp.h
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2019-10-22 16:49:29 -0400
committerNat Goodspeed <nat@lindenlab.com>2020-03-25 19:02:24 -0400
commit28a54c2f7b25b9fda763c51746701f0cd21c8018 (patch)
tree906139d3074d1bc129dde12f8dc2af79599d1dff /indra/test/lltestapp.h
parent253e360062a74cbaf87c7f9dc30ef26bca1697eb (diff)
DRTVWR-476: Infrastructure to help manage long-lived coroutines.
Introduce LLCoros::Stop exception, with subclasses Stopping, Stopped and Shutdown. Add LLCoros::checkStop(), intended to be called periodically by any coroutine with nontrivial lifespan. It checks the LLApp status and, unless isRunning(), throws one of these new exceptions. Make LLCoros::toplevel() catch Stop specially and log forcible coroutine termination. Now that LLApp status matters even in a test program, introduce a trivial LLTestApp subclass whose sole function is to make isRunning() true. (LLApp::setStatus() is protected: only a subclass can call it.) Add LLTestApp instances to lleventcoro_test.cpp and lllogin_test.cpp. Make LLCoros::toplevel() accept parameters by value rather than by const reference so we can continue using them even after context switches. Make private LLCoros::get_CoroData() static. Given that we've observed some coroutines living past LLCoros destruction, making the caller call LLCoros::instance() is more dangerous than encapsulating it within a static method -- since the encapsulated call can check LLCoros::wasDeleted() first and do something reasonable instead. This also eliminates the need for both a const and non-const overload. Defend LLCoros::delete_CoroData() (cleanup function for fiber_specific_ptr for CoroData, implicitly called after coroutine termination) against calls after ~LLCoros(). Add a status string to coroutine-local data, with LLCoro::setStatus(), getStatus() and RAII class TempStatus. Add an optional 'when' string argument to LLCoros::printActiveCoroutines(). Make ~LLCoros() print the coroutines still active at destruction.
Diffstat (limited to 'indra/test/lltestapp.h')
-rw-r--r--indra/test/lltestapp.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/indra/test/lltestapp.h b/indra/test/lltestapp.h
new file mode 100644
index 0000000000..382516cd2b
--- /dev/null
+++ b/indra/test/lltestapp.h
@@ -0,0 +1,34 @@
+/**
+ * @file lltestapp.h
+ * @author Nat Goodspeed
+ * @date 2019-10-21
+ * @brief LLApp subclass useful for testing.
+ *
+ * $LicenseInfo:firstyear=2019&license=viewerlgpl$
+ * Copyright (c) 2019, Linden Research, Inc.
+ * $/LicenseInfo$
+ */
+
+#if ! defined(LL_LLTESTAPP_H)
+#define LL_LLTESTAPP_H
+
+#include "llapp.h"
+
+/**
+ * LLTestApp is a dummy LLApp that simply sets LLApp::isRunning() for anyone
+ * who cares.
+ */
+class LLTestApp: public LLApp
+{
+public:
+ LLTestApp()
+ {
+ setStatus(APP_STATUS_RUNNING);
+ }
+
+ bool init() { return true; }
+ bool cleanup() { return true; }
+ bool frame() { return true; }
+};
+
+#endif /* ! defined(LL_LLTESTAPP_H) */