summaryrefslogtreecommitdiff
path: root/src/mongo/executor/thread_pool_task_executor.h
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2015-11-09 16:42:46 -0500
committerAndy Schwerin <schwerin@mongodb.com>2015-11-09 16:42:46 -0500
commitfa038b8375fd5aea4d359fe0968beb948de58782 (patch)
tree498d82b60295d621e92b7f5f1197349c2532991a /src/mongo/executor/thread_pool_task_executor.h
parentba231028314553f1495e6583d5a59c55919a764c (diff)
downloadmongo-fa038b8375fd5aea4d359fe0968beb948de58782.tar.gz
SERVER-20944 Move as much work as possible outside of ThreadPoolTaskExecutor critical sections.
This patch moves calls to the NetworkInterface and heap allocations out from under the ThreadPoolTaskExecutor's mutex, to minimize critical length and maximize available concurrency.
Diffstat (limited to 'src/mongo/executor/thread_pool_task_executor.h')
-rw-r--r--src/mongo/executor/thread_pool_task_executor.h26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/mongo/executor/thread_pool_task_executor.h b/src/mongo/executor/thread_pool_task_executor.h
index e983c91de49..071d616aeca 100644
--- a/src/mongo/executor/thread_pool_task_executor.h
+++ b/src/mongo/executor/thread_pool_task_executor.h
@@ -94,17 +94,29 @@ private:
using EventList = stdx::list<std::shared_ptr<EventState>>;
/**
- * Creates a new callback on "queue" with the "work" function. If "when" is
- * not Date_t{}, the new callback's readyDate is set to "when".
+ * Structure returned by makeSingletonWork, for passing into enqueueCallbackState_inlock.
*/
- StatusWith<CallbackHandle> enqueueCallbackState_inlock(WorkQueue* queue,
- CallbackFn work,
- Date_t when = {});
+ struct WQEL;
/**
- * Makes a new event object.
+ * Returns an EventList containing one unsignaled EventState. This is a helper function for
+ * performing allocations outside of _mutex, and should only be called by makeSingletonWork and
+ * makeEvent().
*/
- StatusWith<EventHandle> makeEvent_inlock();
+ static EventList makeSingletonEventList();
+
+ /**
+ * Returns an object suitable for passing to enqueueCallbackState_inlock that represents
+ * executing "work" no sooner than "when" (defaults to ASAP). This function may and should be
+ * called outside of _mutex.
+ */
+ static WQEL makeSingletonWork(CallbackFn work, Date_t when = {});
+
+ /**
+ * Creates a new callback on "queue" to do the work described by "wqel", which was
+ * itself produced via makeSingletonWork().
+ */
+ StatusWith<CallbackHandle> enqueueCallbackState_inlock(WorkQueue* queue, WQEL&& wqel);
/**
* Signals the given event.