summaryrefslogtreecommitdiff
path: root/indra/llcommon/workqueue.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2021-10-25 17:31:27 -0400
committerNat Goodspeed <nat@lindenlab.com>2021-10-25 17:31:27 -0400
commit023d39963e850356e1af6eec7f857e2534ce8d38 (patch)
tree3e813e18493e5d74127e4699bc5cf23746965932 /indra/llcommon/workqueue.cpp
parente7b8c27741201528bf78f95c96ba820833923dab (diff)
SL-16220: WorkQueue::runOn() methods submit work, wait for result.
The idea is that you can call runOn(target, callable) from a (non-default) coroutine and block that coroutine until the result becomes available. As a safety check, we forbid calling runOn() from a thread's default coroutine, assuming that a given thread's default coroutine is the one servicing the relevant WorkQueue.
Diffstat (limited to 'indra/llcommon/workqueue.cpp')
-rw-r--r--indra/llcommon/workqueue.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/indra/llcommon/workqueue.cpp b/indra/llcommon/workqueue.cpp
index 114aeea1f3..f7ffc8233c 100644
--- a/indra/llcommon/workqueue.cpp
+++ b/indra/llcommon/workqueue.cpp
@@ -26,6 +26,11 @@
using Mutex = LLCoros::Mutex;
using Lock = LLCoros::LockType;
+struct NotOnDftCoro: public LLException
+{
+ NotOnDftCoro(const std::string& what): LLException(what) {}
+};
+
LL::WorkQueue::WorkQueue(const std::string& name):
super(makeName(name))
{
@@ -136,3 +141,13 @@ void LL::WorkQueue::error(const std::string& msg)
{
LL_ERRS("WorkQueue") << msg << LL_ENDL;
}
+
+void LL::WorkQueue::checkCoroutine(const std::string& method)
+{
+ // By convention, the default coroutine on each thread has an empty name
+ // string. See also LLCoros::logname().
+ if (LLCoros::getName().empty())
+ {
+ LLTHROW(NotOnDftCoro("Do not call " + method + " from a thread's default coroutine"));
+ }
+}