Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81525 - in trunk: boost/thread libs/thread/doc libs/thread/test libs/thread/test/sync/mutual_exclusion/locks/lock_guard libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons
From: vicente.botet_at_[hidden]
Date: 2012-11-25 03:19:42


Author: viboes
Date: 2012-11-25 03:19:40 EST (Sun, 25 Nov 2012)
New Revision: 81525
URL: http://svn.boost.org/trac/boost/changeset/81525

Log:
Thread: update docs and some licenses
Text files modified:
   trunk/boost/thread/lock_factories.hpp | 3 +--
   trunk/libs/thread/doc/compliance.qbk | 2 +-
   trunk/libs/thread/doc/mutex_concepts.qbk | 36 ++++++++++++++++++++++++++++++++++++
   trunk/libs/thread/doc/sync_tutorial.qbk | 27 ++++++++++++++++++++++++++-
   trunk/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/make_lock_guard_pass.cpp | 2 +-
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_adopt_lock_pass.cpp | 11 +----------
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_defer_lock_pass.cpp | 11 +----------
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_mutex_pass.cpp | 11 +----------
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_try_to_lock_pass.cpp | 11 +----------
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_locks_mutex_pass.cpp | 11 +----------
   trunk/libs/thread/test/test_4882.cpp | 31 ++++++++++++++++---------------
   11 files changed, 86 insertions(+), 70 deletions(-)

Modified: trunk/boost/thread/lock_factories.hpp
==============================================================================
--- trunk/boost/thread/lock_factories.hpp (original)
+++ trunk/boost/thread/lock_factories.hpp 2012-11-25 03:19:40 EST (Sun, 25 Nov 2012)
@@ -1,8 +1,7 @@
 // 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)
-// (C) Copyright 2007 Anthony Williams
-// (C) Copyright 2011-2012 Vicente J. Botet Escriba
+// (C) Copyright 2012 Vicente J. Botet Escriba
 
 #ifndef BOOST_THREAD_LOCK_FACTORIES_HPP
 #define BOOST_THREAD_LOCK_FACTORIES_HPP

Modified: trunk/libs/thread/doc/compliance.qbk
==============================================================================
--- trunk/libs/thread/doc/compliance.qbk (original)
+++ trunk/libs/thread/doc/compliance.qbk 2012-11-25 03:19:40 EST (Sun, 25 Nov 2012)
@@ -45,7 +45,7 @@
     [[30.4.1.3] [Timed mutex types] [Yes] [-] [-]]
     [[30.4.1.3.1] [Class timed_mutex] [Yes] [-] [-]]
     [[30.4.1.3.1] [Class recursive_timed_mutex] [Yes] [-] [-]]
- [[30.4.2] [Locks] [Partial] [variadic] [#6227]]
+ [[30.4.2] [Locks] [Yes] [-] [-]]
     [[30.4.2.1] [Class template lock_guard] [Yes] [-] [-]]
     [[30.4.2.2] [Class template unique_lock] [Yes] [-] [-]]
     [[30.4.2.2.1] [unique_lock constructors, destructor, and assignment] [Yes] [-] [-]]

Modified: trunk/libs/thread/doc/mutex_concepts.qbk
==============================================================================
--- trunk/libs/thread/doc/mutex_concepts.qbk (original)
+++ trunk/libs/thread/doc/mutex_concepts.qbk 2012-11-25 03:19:40 EST (Sun, 25 Nov 2012)
@@ -948,6 +948,10 @@
 
     template<typename Lockable>
     class lock_guard
+ template <typename Lockable>
+ lock_guard<Lockable> make_lock_guard(Lockable& mtx); // EXTENSION
+ template <typename Lockable>
+ lock_guard<Lockable> make_lock_guard(Lockable& mtx, adopt_lock_t); // EXTENSION
   }
 
 [section:lock_guard Class template `lock_guard`]
@@ -1017,6 +1021,38 @@
 
 [endsect]
   
+[section:make_lock_guard Non Member Function `make_lock_guard`]
+
+ template <typename Lockable>
+ lock_guard<Lockable> make_lock_guard(Lockable& m); // EXTENSION
+
+
+[variablelist
+
+[[Returns:] [a lock_guard as if initialized with `{m}`.]]
+
+[[Throws:] [Any exception thrown by the call to [lock_ref_link `m.lock()`].]]
+
+]
+
+
+[endsect]
+[section:make_lock_guard_adopt Non Member Function `make_lock_guard`]
+
+ template <typename Lockable>
+ lock_guard<Lockable> make_lock_guard(Lockable& m, adopt_lock_t); // EXTENSION
+
+
+[variablelist
+
+[[Returns:] [a lock_guard as if initialized with `{m, adopt_lock}`.]]
+
+[[Throws:] [Any exception thrown by the call to [lock_ref_link `m.lock()`].]]
+
+]
+
+
+[endsect]
 [endsect]
 
 [section:lock_concepts Lock Concepts]

Modified: trunk/libs/thread/doc/sync_tutorial.qbk
==============================================================================
--- trunk/libs/thread/doc/sync_tutorial.qbk (original)
+++ trunk/libs/thread/doc/sync_tutorial.qbk 2012-11-25 03:19:40 EST (Sun, 25 Nov 2012)
@@ -11,4 +11,29 @@
 
 [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2406.html Mutex, Lock, Condition Variable Rationale] adds rationale for the design decisions made for mutexes, locks and condition variables.
 
-[endsect]
+[section:locks Locks]
+
+In addition to the C++11 standard locks, Boost.Thread provides other locks and some utilities that help the user to make their code thread-safe.
+
+In particular, the library provides some lock factories.
+
+ template <class Lockable, class Function>
+ auto with_lock_guard(Lockable& m, Function f) -> decltype(fn())
+ {
+ auto&& _ = boost::make_lock_guard(f);
+ f();
+ }
+
+
+that can be used as
+
+ int i = with_lock_guard(mtx, {}() -> bool
+ {
+ // access the protected state
+ return true;
+ });
+
+
+[endsect] [/ Locks]
+
+[endsect] [/ Tutorial]

Modified: trunk/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/make_lock_guard_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/make_lock_guard_pass.cpp (original)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/lock_guard/make_lock_guard_pass.cpp 2012-11-25 03:19:40 EST (Sun, 25 Nov 2012)
@@ -45,7 +45,7 @@
   time_point t0 = Clock::now();
   time_point t1;
   {
- auto&& lg = boost::make_lock_guard(m);
+ const auto&& lg = boost::make_lock_guard(m);
     t1 = Clock::now();
     BOOST_THREAD_TRACE;
   }

Modified: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_adopt_lock_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_adopt_lock_pass.cpp (original)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_adopt_lock_pass.cpp 2012-11-25 03:19:40 EST (Sun, 25 Nov 2012)
@@ -1,13 +1,4 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// Copyright (C) 2011 Vicente J. Botet Escriba
+// 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)

Modified: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_defer_lock_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_defer_lock_pass.cpp (original)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_defer_lock_pass.cpp 2012-11-25 03:19:40 EST (Sun, 25 Nov 2012)
@@ -1,13 +1,4 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// Copyright (C) 2011 Vicente J. Botet Escriba
+// 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)

Modified: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_mutex_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_mutex_pass.cpp (original)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_mutex_pass.cpp 2012-11-25 03:19:40 EST (Sun, 25 Nov 2012)
@@ -1,13 +1,4 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// Copyright (C) 2011 Vicente J. Botet Escriba
+// 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)

Modified: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_try_to_lock_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_try_to_lock_pass.cpp (original)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_try_to_lock_pass.cpp 2012-11-25 03:19:40 EST (Sun, 25 Nov 2012)
@@ -1,13 +1,4 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// Copyright (C) 2011 Vicente J. Botet Escriba
+// 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)

Modified: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_locks_mutex_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_locks_mutex_pass.cpp (original)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_locks_mutex_pass.cpp 2012-11-25 03:19:40 EST (Sun, 25 Nov 2012)
@@ -1,13 +1,4 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// Copyright (C) 2011 Vicente J. Botet Escriba
+// 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)

Modified: trunk/libs/thread/test/test_4882.cpp
==============================================================================
--- trunk/libs/thread/test/test_4882.cpp (original)
+++ trunk/libs/thread/test/test_4882.cpp 2012-11-25 03:19:40 EST (Sun, 25 Nov 2012)
@@ -4,61 +4,61 @@
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
 #define BOOST_THREAD_VERSION 2
+#define BOOST_THREAD_USES_LOG
 
 #include <boost/thread/thread.hpp>
 #include <boost/thread/shared_mutex.hpp>
 #include <boost/detail/no_exceptions_support.hpp>
-
-#include <iostream>
+#include <boost/thread/detail/log.hpp>
 
 boost::shared_mutex mutex;
 
 void thread()
 {
- std::cout << __FILE__ << ":" << __LINE__ << std::endl;
+ BOOST_THREAD_LOG << "<thrd" << BOOST_THREAD_END_LOG;
   BOOST_TRY
   {
     for (int i =0; i<10; ++i)
     {
-#if 0
+#ifndef BOOST_THREAD_USES_CHRONO
       boost::system_time timeout = boost::get_system_time() + boost::posix_time::milliseconds(50);
 
       if (mutex.timed_lock(timeout))
       {
- std::cout << __FILE__ << ":" << __LINE__ << " i="<<i << std::endl;
+ BOOST_THREAD_LOG << "<thrd" << " i="<<i << BOOST_THREAD_END_LOG;
         boost::this_thread::sleep(boost::posix_time::milliseconds(10));
         mutex.unlock();
- std::cout << __FILE__ << ":" << __LINE__ << " i="<<i << std::endl;
+ BOOST_THREAD_LOG << "<thrd" << " i="<<i << BOOST_THREAD_END_LOG;
       }
 #else
       boost::chrono::system_clock::time_point timeout = boost::chrono::system_clock::now() + boost::chrono::milliseconds(50);
 
- std::cout << __FILE__ << ":" << __LINE__ << " i="<<i << std::endl;
+ BOOST_THREAD_LOG << "<thrd" << " i="<<i << BOOST_THREAD_END_LOG;
       if (mutex.try_lock_until(timeout))
       {
- std::cout << __FILE__ << ":" << __LINE__ << " i="<<i << std::endl;
+ BOOST_THREAD_LOG << "<thrd" << " i="<<i << BOOST_THREAD_END_LOG;
         boost::this_thread::sleep_for(boost::chrono::milliseconds(10));
         mutex.unlock();
- std::cout << __FILE__ << ":" << __LINE__ << " i="<<i << std::endl;
+ BOOST_THREAD_LOG << "<thrd" << " i="<<i << BOOST_THREAD_END_LOG;
       }
 #endif
     }
   }
   BOOST_CATCH (boost::lock_error& le)
   {
- std::cerr << "lock_error exception\n";
+ BOOST_THREAD_LOG << "lock_error exception thrd>" << BOOST_THREAD_END_LOG;
   }
   BOOST_CATCH (...)
   {
- std::cerr << " exception\n";
+ BOOST_THREAD_LOG << "exception thrd>" << BOOST_THREAD_END_LOG;
   }
   BOOST_CATCH_END
- std::cout << __FILE__ << ":" << __LINE__ << std::endl;
+ BOOST_THREAD_LOG << "thrd>" << BOOST_THREAD_END_LOG;
 }
 
 int main()
 {
- std::cout << __FILE__ << ":" << __LINE__ << std::endl;
+ BOOST_THREAD_LOG << "<main" << BOOST_THREAD_END_LOG;
   const int nrThreads = 20;
   boost::thread* threads[nrThreads];
 
@@ -68,9 +68,10 @@
   for (int i = 0; i < nrThreads; ++i)
   {
     threads[i]->join();
- std::cout << __FILE__ << ":" << __LINE__ << std::endl;
+ BOOST_THREAD_LOG << "main" << BOOST_THREAD_END_LOG;
     delete threads[i];
+ BOOST_THREAD_LOG << "main" << BOOST_THREAD_END_LOG;
   }
- std::cout << __FILE__ << ":" << __LINE__ << std::endl;
+ BOOST_THREAD_LOG << "main>" << BOOST_THREAD_END_LOG;
   return 0;
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk