$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r81504 - trunk/boost/thread/detail
From: vicente.botet_at_[hidden]
Date: 2012-11-24 02:20:22
Author: viboes
Date: 2012-11-24 02:20:21 EST (Sat, 24 Nov 2012)
New Revision: 81504
URL: http://svn.boost.org/trac/boost/changeset/81504
Log:
Thread: added internal thread-safe log utility
Added:
   trunk/boost/thread/detail/log.hpp   (contents, props changed)
Added: trunk/boost/thread/detail/log.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/thread/detail/log.hpp	2012-11-24 02:20:21 EST (Sat, 24 Nov 2012)
@@ -0,0 +1,72 @@
+// Copyright (C) 2012 Vicente J. Botet Escriba
+//
+//  Distributed under the Boost Software License, Version 1.0. (See accompanying
+//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_THREAD_DETAIL_LOG_HPP
+#define BOOST_THREAD_DETAIL_LOG_HPP
+
+#include <boost/thread/detail/config.hpp>
+#if defined BOOST_THREAD_USES_LOG
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/thread/thread.hpp>
+#include <iostream>
+
+namespace boost
+{
+  namespace thread_detail
+  {
+    inline boost::recursive_mutex& terminal_mutex()
+    {
+      static boost::recursive_mutex mtx;
+      return mtx;
+    }
+
+  }
+}
+
+#define BOOST_THREAD_LOG \
+  { \
+    boost::lock_guard<boost::recursive_mutex> lk(boost::thread_detail::terminal_mutex()); \
+    std::cout << boost::this_thread::get_id() << " - "<<__FILE__<<"["<<__LINE__<<"] " <<std::dec
+
+#define BOOST_THREAD_END_LOG \
+    std::dec << std::endl; \
+  }
+
+#else
+
+namespace boost
+{
+  namespace thread_detail
+  {
+    struct dummy_stream_t
+    {
+    };
+
+    template <typename T>
+    inline dummy_stream_t const& operator<<(dummy_stream_t const& os, T)
+    {
+      return os;
+    }
+
+    inline dummy_stream_t const& operator<<(dummy_stream_t const& os, dummy_stream_t const&)
+    {
+      return os;
+    }
+
+
+    BOOST_CONSTEXPR_OR_CONST dummy_stream_t dummy_stream = {};
+
+  }
+}
+
+#define BOOST_THREAD_LOG if (true) {} else boost::thread_detail::dummy_stream
+#define BOOST_THREAD_END_LOG boost::thread_detail::dummy_stream
+
+#endif
+
+#define BOOST_THREAD_TRACE BOOST_THREAD_LOG << BOOST_THREAD_END_LOG
+
+
+#endif // header