*/
mutable Threads::ThreadLocalStorage<std::stack<std::string>> prefixes;
+ /**
+ * We record the thread id of the thread creating this object. We need
+ * this information to "steal" the current prefix from this "master"
+ * thread on first use of deallog on a new thread.
+ */
+ std::thread::id master_thread;
+
/**
* Default stream, where the output is to go to. This stream defaults to
* <tt>std::cout</tt>, but can be set to another stream through the
get_stream();
/**
- * We use tbb's thread local storage facility to generate a stringstream for
+ * We use our thread local storage facility to generate a stringstream for
* every thread that sends log messages.
*/
Threads::ThreadLocalStorage<std::shared_ptr<std::ostringstream>> outstreams;
/*!@addtogroup threads */
/*@{*/
+# ifndef DOXYGEN
+class LogStream;
+# endif
namespace Threads
{
* An exemplar for creating a new (thread specific) copy.
*/
std::shared_ptr<const T> exemplar;
+
+ friend class dealii::LogStream;
};
} // namespace Threads
/**
LogStream::LogStream()
- : std_out(&std::cout)
+ : master_thread(std::this_thread::get_id())
+ , std_out(&std::cout)
, file(nullptr)
, std_depth(0)
, file_depth(10000)
bool exists = false;
std::stack<std::string> &local_prefixes = prefixes.get(exists);
-# if 0 // FIXME
// If this is a new locally stored stack, copy the "blessed" prefixes
// from the initial thread that created logstream.
if (!exists)
{
- const tbb::enumerable_thread_specific<std::stack<std::string>> &impl =
- prefixes.get_implementation();
-
- // The thread that created this LogStream object should be the first
- // in tbb's enumerable_thread_specific container.
- const tbb::enumerable_thread_specific<
- std::stack<std::string>>::const_iterator first_elem = impl.begin();
-
- if (first_elem != impl.end())
- {
- local_prefixes = *first_elem;
- }
+ auto it = prefixes.data.find(master_thread);
+ if (it != prefixes.data.end())
+ local_prefixes = it->second;
}
-# endif
return local_prefixes;