summaryrefslogtreecommitdiff
path: root/indra/llcommon/workqueue.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/workqueue.h')
-rw-r--r--indra/llcommon/workqueue.h31
1 files changed, 23 insertions, 8 deletions
diff --git a/indra/llcommon/workqueue.h b/indra/llcommon/workqueue.h
index 9d7bbfbf7a..ecc6f27223 100644
--- a/indra/llcommon/workqueue.h
+++ b/indra/llcommon/workqueue.h
@@ -3,7 +3,7 @@
* @author Nat Goodspeed
* @date 2021-09-30
* @brief Queue used for inter-thread work passing.
- *
+ *
* $LicenseInfo:firstyear=2021&license=viewerlgpl$
* Copyright (c) 2021, Linden Research, Inc.
* $/LicenseInfo$
@@ -13,6 +13,7 @@
#define LL_WORKQUEUE_H
#include "llcoros.h"
+#include "llevents.h"
#include "llexception.h"
#include "llinstancetracker.h"
#include "llinstancetrackersubclass.h"
@@ -116,16 +117,29 @@ namespace LL
ARGS&&... args);
/**
- * Post work to another WorkQueue, blocking the calling coroutine
- * until then, returning the result to caller on completion. Optional
- * final argument is TimePoint for WorkSchedule.
+ * Post work, blocking the calling coroutine, returning the result to
+ * caller on completion. Optional final argument is TimePoint for
+ * WorkSchedule.
*
* In general, we assume that each thread's default coroutine is busy
* servicing its WorkQueue or whatever. To try to prevent mistakes, we
* forbid calling waitForResult() from a thread's default coroutine.
*/
template <typename CALLABLE, typename... ARGS>
- auto waitForResult(CALLABLE&& callable, ARGS&&... args);
+ auto waitForResult(CALLABLE&& callable, ARGS&&... args)
+ {
+ checkCoroutine("waitForResult()");
+ return waitForResult_(std::forward<CALLABLE>(callable),
+ std::forward<ARGS>(args)...);
+ }
+
+ /**
+ * Post work, blocking the calling coroutine, returning the result to
+ * caller on completion. Optional final argument is TimePoint for
+ * WorkSchedule.
+ */
+ template <typename CALLABLE, typename... ARGS>
+ auto waitForResult_(CALLABLE&& callable, ARGS&&... args);
/*--------------------------- worker API ---------------------------*/
@@ -194,6 +208,8 @@ namespace LL
static std::string makeName(const std::string& name);
void callWork(const Work& work);
+ LLTempBoundListener mStopListener;
+
private:
virtual Work pop_() = 0;
virtual bool tryPop_(Work&) = 0;
@@ -525,7 +541,7 @@ namespace LL
reply,
// Bind the current exception to transport back to the
// originating WorkQueue. Once there, rethrow it.
- [exc = std::current_exception()](){ std::rethrow_exception(exc); });
+ [exc = std::current_exception()]{ std::rethrow_exception(exc); });
}
},
// if caller passed a TimePoint, pass it along to post()
@@ -618,9 +634,8 @@ namespace LL
};
template <typename CALLABLE, typename... ARGS>
- auto WorkQueueBase::waitForResult(CALLABLE&& callable, ARGS&&... args)
+ auto WorkQueueBase::waitForResult_(CALLABLE&& callable, ARGS&&... args)
{
- checkCoroutine("waitForResult()");
// derive callable's return type so we can specialize for void
return WaitForResult<CALLABLE, decltype(std::forward<CALLABLE>(callable)())>()
(this, std::forward<CALLABLE>(callable), std::forward<ARGS>(args)...);