diff options
author | Andrew Morrow <acm@mongodb.com> | 2017-02-26 15:15:08 -0500 |
---|---|---|
committer | Andrew Morrow <acm@mongodb.com> | 2017-08-02 23:29:55 -0400 |
commit | a8a1ea3b9367adb6d0b65a7da21fed89598ea093 (patch) | |
tree | 8e969ed54b88c2a9c4c2d45a6518d053ac9f4265 /src/mongo/logger | |
parent | c02c14e30d75b02894da116f4bb1a71652ead2b4 (diff) | |
download | mongo-a8a1ea3b9367adb6d0b65a7da21fed89598ea093.tar.gz |
SERVER-26538 SERVER-26539 Detach from boost::thread
Also, use thread_local everywhere for our thread specific data needs
and remove the legacy support.
Diffstat (limited to 'src/mongo/logger')
-rw-r--r-- | src/mongo/logger/logstream_builder.cpp | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/mongo/logger/logstream_builder.cpp b/src/mongo/logger/logstream_builder.cpp index f0dfbaeebe9..fcafdfd425f 100644 --- a/src/mongo/logger/logstream_builder.cpp +++ b/src/mongo/logger/logstream_builder.cpp @@ -37,7 +37,6 @@ #include "mongo/logger/tee.h" #include "mongo/stdx/memory.h" #include "mongo/util/assert_util.h" // TODO: remove apple dep for this in threadlocal.h -#include "mongo/util/concurrency/threadlocal.h" #include "mongo/util/time_support.h" namespace mongo { @@ -54,20 +53,17 @@ MONGO_INITIALIZER(LogstreamBuilder)(InitializerContext*) { return Status::OK(); } -} // namespace - -TSP_DECLARE(std::unique_ptr<std::ostringstream>, threadOstreamCache); -TSP_DEFINE(std::unique_ptr<std::ostringstream>, threadOstreamCache); +thread_local std::unique_ptr<std::ostringstream> threadOstreamCache; -namespace { // During unittests, where we don't use quickExit(), static finalization may destroy the // cache before its last use, so mark it as not initialized in that case. -// This must be after the TSP_DEFINE so that it is destroyed first. +// This must be after the definition of threadOstreamCache so that it is destroyed first. struct ThreadOstreamCacheFinalizer { ~ThreadOstreamCacheFinalizer() { isThreadOstreamCacheInitialized = false; } } threadOstreamCacheFinalizer; + } // namespace namespace logger { @@ -112,9 +108,8 @@ LogstreamBuilder::~LogstreamBuilder() { _tee->write(_os->str()); } _os->str(""); - if (_shouldCache && isThreadOstreamCacheInitialized && - !threadOstreamCache.getMake()->get()) { - *threadOstreamCache.get() = std::move(_os); + if (_shouldCache && isThreadOstreamCacheInitialized && !threadOstreamCache) { + threadOstreamCache = std::move(_os); } } } @@ -127,9 +122,8 @@ void LogstreamBuilder::operator<<(Tee* tee) { void LogstreamBuilder::makeStream() { if (!_os) { - if (_shouldCache && isThreadOstreamCacheInitialized && - threadOstreamCache.getMake()->get()) { - _os = std::move(*threadOstreamCache.get()); + if (_shouldCache && isThreadOstreamCacheInitialized && threadOstreamCache) { + _os = std::move(threadOstreamCache); } else { _os = stdx::make_unique<std::ostringstream>(); } |