summaryrefslogtreecommitdiff
path: root/src/mongo/util/executor_test_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/util/executor_test_util.h')
-rw-r--r--src/mongo/util/executor_test_util.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/mongo/util/executor_test_util.h b/src/mongo/util/executor_test_util.h
index b6fa216e446..665651f53dd 100644
--- a/src/mongo/util/executor_test_util.h
+++ b/src/mongo/util/executor_test_util.h
@@ -35,9 +35,10 @@ namespace mongo {
/**
* An "OutOfLineExecutor" that actually runs on the same thread of execution
* This executor is not thread-safe, and accessing it by multiple threads is prohibited.
- * Multi-threaded accesses to instances of "InlineCountingExecutor" result in undefined behavior.
+ * Multi-threaded accesses to instances of "InlineQueuedCountingExecutor" result in undefined
+ * behavior.
*/
-class InlineCountingExecutor : public OutOfLineExecutor {
+class InlineQueuedCountingExecutor : public OutOfLineExecutor {
public:
void schedule(Task task) override {
// Add the task to our queue
@@ -68,7 +69,7 @@ public:
}
static auto make() {
- return std::make_shared<InlineCountingExecutor>();
+ return std::make_shared<InlineQueuedCountingExecutor>();
}
bool inSchedule;
@@ -77,6 +78,22 @@ public:
std::atomic<uint32_t> tasksRun{0}; // NOLINT
};
+class InlineRecursiveCountingExecutor final : public OutOfLineExecutor {
+public:
+ void schedule(Task task) noexcept override {
+ // Relaxed to avoid adding synchronization where there otherwise wouldn't be. That would
+ // cause a false negative from TSAN.
+ tasksRun.fetch_add(1, std::memory_order_relaxed);
+ task(Status::OK());
+ }
+
+ static auto make() {
+ return std::make_shared<InlineRecursiveCountingExecutor>();
+ }
+
+ std::atomic<int32_t> tasksRun{0}; // NOLINT
+};
+
class RejectingExecutor final : public OutOfLineExecutor {
public:
void schedule(Task task) noexcept override {