diff options
author | matt dannenberg <matt.dannenberg@10gen.com> | 2014-10-27 05:24:02 -0400 |
---|---|---|
committer | matt dannenberg <matt.dannenberg@10gen.com> | 2014-10-28 10:38:35 -0400 |
commit | 4752c4631525b7d26599fb89a0ae18784ebbcc73 (patch) | |
tree | d7cc15559d940d98513424b78dde3a9403bc4a36 /src/mongo/db/client.h | |
parent | 18e5b98a603def84221460745f5f3e1566a7e775 (diff) | |
download | mongo-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.h | 17 |
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 */ |