summaryrefslogtreecommitdiff
path: root/src/mongo/db/client.h
diff options
context:
space:
mode:
authormatt dannenberg <matt.dannenberg@10gen.com>2014-10-27 05:24:02 -0400
committermatt dannenberg <matt.dannenberg@10gen.com>2014-10-28 10:38:35 -0400
commit4752c4631525b7d26599fb89a0ae18784ebbcc73 (patch)
treed7cc15559d940d98513424b78dde3a9403bc4a36 /src/mongo/db/client.h
parent18e5b98a603def84221460745f5f3e1566a7e775 (diff)
downloadmongo-4752c4631525b7d26599fb89a0ae18784ebbcc73.tar.gz
SERVER-15780 improve thread naming, remove any hex identifiers from names
Diffstat (limited to 'src/mongo/db/client.h')
-rw-r--r--src/mongo/db/client.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/mongo/db/client.h b/src/mongo/db/client.h
index 764eaf9a0a7..cfbaa38cab8 100644
--- a/src/mongo/db/client.h
+++ b/src/mongo/db/client.h
@@ -42,6 +42,7 @@
#include "mongo/db/lasterror.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/operation_context.h"
+#include "mongo/stdx/functional.h"
#include "mongo/util/concurrency/threadlocal.h"
#include "mongo/util/paths.h"
@@ -74,12 +75,26 @@ namespace mongo {
*/
static void initThread(const char *desc, AbstractMessagingPort *mp = 0);
+ /**
+ * Inits a thread if that thread has not already been init'd, setting the thread name to
+ * "desc".
+ */
static void initThreadIfNotAlready(const char *desc) {
- if( currentClient.get() )
+ if (currentClient.get())
return;
initThread(desc);
}
+ /**
+ * Inits a thread if that thread has not already been init'd, setting the thread name to
+ * the string returned by "nameCallback".
+ */
+ static void initThreadIfNotAlready(stdx::function<std::string ()>& nameCallback) {
+ if (currentClient.get())
+ return;
+ initThread(nameCallback().c_str());
+ }
+
/** this has to be called as the client goes away, but before thread termination
* @return true if anything was done
*/