Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r78240 - in trunk: boost/thread boost/thread/detail boost/thread/pthread libs/thread/test
From: vicente.botet_at_[hidden]
Date: 2012-04-28 08:25:30


Author: viboes
Date: 2012-04-28 08:25:28 EDT (Sat, 28 Apr 2012)
New Revision: 78240
URL: http://svn.boost.org/trac/boost/changeset/78240

Log:
Thread: Refactor the no-copyable classes using the macro BOOST_THREAD_NO_COPYABLE
Text files modified:
   trunk/boost/thread/detail/platform.hpp | 3 ++-
   trunk/boost/thread/detail/thread_interruption.hpp | 22 +++-------------------
   trunk/boost/thread/pthread/condition_variable.hpp | 11 +----------
   trunk/boost/thread/pthread/mutex.hpp | 20 +-------------------
   trunk/boost/thread/pthread/once.hpp | 12 ++----------
   trunk/boost/thread/pthread/recursive_mutex.hpp | 19 +------------------
   trunk/boost/thread/pthread/shared_mutex.hpp | 11 +----------
   trunk/boost/thread/reverse_lock.hpp | 10 +---------
   trunk/boost/thread/shared_lock_guard.hpp | 10 +---------
   trunk/libs/thread/test/test_6130.cpp | 34 +++++++++++++++++++++-------------
   10 files changed, 34 insertions(+), 118 deletions(-)

Modified: trunk/boost/thread/detail/platform.hpp
==============================================================================
--- trunk/boost/thread/detail/platform.hpp (original)
+++ trunk/boost/thread/detail/platform.hpp 2012-04-28 08:25:28 EDT (Sat, 28 Apr 2012)
@@ -35,6 +35,7 @@
 # define BOOST_THREAD_BEOS
 #elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
 # define BOOST_THREAD_MACOS
+# define BOOST_THREAD_WAIT_BUG
 #elif defined(__IBMCPP__) || defined(_AIX)
 # define BOOST_THREAD_AIX
 #elif defined(__amigaos__)
@@ -55,7 +56,7 @@
 // dispatcher table. If there is no entry for a platform but pthreads is
 // available on the platform, pthread is choosen as default. If nothing is
 // available the preprocessor will fail with a diagnostic message.
-
+
 #if defined(BOOST_THREAD_POSIX)
 # define BOOST_THREAD_PLATFORM_PTHREAD
 #else

Modified: trunk/boost/thread/detail/thread_interruption.hpp
==============================================================================
--- trunk/boost/thread/detail/thread_interruption.hpp (original)
+++ trunk/boost/thread/detail/thread_interruption.hpp 2012-04-28 08:25:28 EDT (Sat, 28 Apr 2012)
@@ -7,6 +7,7 @@
 // (C) Copyright 2012 Vicente J. Botet Escriba
 
 #include <boost/thread/detail/config.hpp>
+#include <boost/thread/detail/delete.hpp>
 
 namespace boost
 {
@@ -17,15 +18,7 @@
           bool interruption_was_enabled;
           friend class restore_interruption;
         public:
-#ifndef BOOST_NO_DELETED_FUNCTIONS
- disable_interruption(const disable_interruption&) = delete;
- disable_interruption& operator=(const disable_interruption&) = delete;
-#else
- private:
- disable_interruption(const disable_interruption&);
- disable_interruption& operator=(const disable_interruption&);
- public:
-#endif
+ BOOST_THREAD_NO_COPYABLE(disable_interruption)
             disable_interruption() BOOST_NOEXCEPT;
             ~disable_interruption() BOOST_NOEXCEPT;
         };
@@ -33,16 +26,7 @@
         class BOOST_THREAD_DECL restore_interruption
         {
         public:
-#ifndef BOOST_NO_DELETED_FUNCTIONS
- restore_interruption(const restore_interruption&) = delete;
- restore_interruption& operator=(const restore_interruption&) = delete;
-#else
- private:
- restore_interruption(const restore_interruption&);
- restore_interruption& operator=(const restore_interruption&);
- public:
-#endif
-
+ BOOST_THREAD_NO_COPYABLE(restore_interruption)
             explicit restore_interruption(disable_interruption& d) BOOST_NOEXCEPT;
             ~restore_interruption() BOOST_NOEXCEPT;
         };

Modified: trunk/boost/thread/pthread/condition_variable.hpp
==============================================================================
--- trunk/boost/thread/pthread/condition_variable.hpp (original)
+++ trunk/boost/thread/pthread/condition_variable.hpp 2012-04-28 08:25:28 EDT (Sat, 28 Apr 2012)
@@ -14,6 +14,7 @@
 #include <boost/chrono/system_clocks.hpp>
 #include <boost/chrono/ceil.hpp>
 #endif
+#include <boost/thread/detail/delete.hpp>
 
 #include <boost/config/abi_prefix.hpp>
 
@@ -111,16 +112,6 @@
         pthread_mutex_t internal_mutex;
         pthread_cond_t cond;
 
-//#ifndef BOOST_NO_DELETED_FUNCTIONS
-// public:
-// condition_variable_any(condition_variable_any const&) = delete;
-// condition_variable_any& operator=(condition_variable_any const&) = delete;
-//#else // BOOST_NO_DELETED_FUNCTIONS
-// private:
-// condition_variable_any(condition_variable_any&);
-// condition_variable_any& operator=(condition_variable_any&);
-//#endif // BOOST_NO_DELETED_FUNCTIONS
-
     public:
         BOOST_THREAD_NO_COPYABLE(condition_variable_any)
         condition_variable_any()

Modified: trunk/boost/thread/pthread/mutex.hpp
==============================================================================
--- trunk/boost/thread/pthread/mutex.hpp (original)
+++ trunk/boost/thread/pthread/mutex.hpp 2012-04-28 08:25:28 EDT (Sat, 28 Apr 2012)
@@ -21,6 +21,7 @@
 #include <boost/chrono/system_clocks.hpp>
 #include <boost/chrono/ceil.hpp>
 #endif
+#include <boost/thread/detail/delete.hpp>
 
 #ifdef _POSIX_TIMEOUTS
 #if _POSIX_TIMEOUTS >= 0 && _POSIX_C_SOURCE>=200112L
@@ -34,15 +35,6 @@
 {
     class mutex
     {
-//#ifndef BOOST_NO_DELETED_FUNCTIONS
-// public:
-// mutex(mutex const&) = delete;
-// mutex& operator=(mutex const&) = delete;
-//#else // BOOST_NO_DELETED_FUNCTIONS
-// private:
-// mutex(mutex const&);
-// mutex& operator=(mutex const&);
-//#endif // BOOST_NO_DELETED_FUNCTIONS
     private:
         pthread_mutex_t m;
     public:
@@ -122,16 +114,6 @@
 
     class timed_mutex
     {
-//#ifndef BOOST_NO_DELETED_FUNCTIONS
-// public:
-// timed_mutex(timed_mutex const&) = delete;
-// timed_mutex& operator=(timed_mutex const&) = delete;
-//#else // BOOST_NO_DELETED_FUNCTIONS
-// private:
-// timed_mutex(timed_mutex const&);
-// timed_mutex& operator=(timed_mutex const&);
-// public:
-//#endif // BOOST_NO_DELETED_FUNCTIONS
     private:
         pthread_mutex_t m;
 #ifndef BOOST_PTHREAD_HAS_TIMEDLOCK

Modified: trunk/boost/thread/pthread/once.hpp
==============================================================================
--- trunk/boost/thread/pthread/once.hpp (original)
+++ trunk/boost/thread/pthread/once.hpp 2012-04-28 08:25:28 EDT (Sat, 28 Apr 2012)
@@ -16,6 +16,7 @@
 #include <boost/assert.hpp>
 #include <boost/thread/pthread/pthread_mutex_scoped_lock.hpp>
 #include <boost/cstdint.hpp>
+#include <boost/thread/detail/delete.hpp>
 
 #include <boost/config/abi_prefix.hpp>
 
@@ -28,19 +29,10 @@
 
   struct once_flag
   {
- BOOST_THREAD_NO_COPYABLE(once_flag)
+ BOOST_THREAD_NO_COPYABLE(once_flag)
       BOOST_CONSTEXPR once_flag() BOOST_NOEXCEPT
         : epoch(BOOST_ONCE_INITIAL_FLAG_VALUE)
       {}
-//#ifndef BOOST_NO_DELETED_FUNCTIONS
-// once_flag(const once_flag&) = delete;
-// once_flag& operator=(const once_flag&) = delete;
-//#else // BOOST_NO_DELETED_FUNCTIONS
-// private:
-// once_flag(once_flag&);
-// once_flag& operator=(once_flag&);
-// public:
-//#endif // BOOST_NO_DELETED_FUNCTIONS
   private:
       boost::uintmax_t epoch;
       template<typename Function>

Modified: trunk/boost/thread/pthread/recursive_mutex.hpp
==============================================================================
--- trunk/boost/thread/pthread/recursive_mutex.hpp (original)
+++ trunk/boost/thread/pthread/recursive_mutex.hpp 2012-04-28 08:25:28 EDT (Sat, 28 Apr 2012)
@@ -24,6 +24,7 @@
 #include <boost/chrono/system_clocks.hpp>
 #include <boost/chrono/ceil.hpp>
 #endif
+#include <boost/thread/detail/delete.hpp>
 
 #ifdef _POSIX_TIMEOUTS
 #if _POSIX_TIMEOUTS >= 0
@@ -41,15 +42,6 @@
 {
     class recursive_mutex
     {
-//#ifndef BOOST_NO_DELETED_FUNCTIONS
-// public:
-// recursive_mutex(recursive_mutex const&) = delete;
-// recursive_mutex& operator=(recursive_mutex const&) = delete;
-//#else // BOOST_NO_DELETED_FUNCTIONS
-// private:
-// recursive_mutex(recursive_mutex const&);
-// recursive_mutex& operator=(recursive_mutex const&);
-//#endif // BOOST_NO_DELETED_FUNCTIONS
     private:
         pthread_mutex_t m;
 #ifndef BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE
@@ -184,15 +176,6 @@
 
     class recursive_timed_mutex
     {
-//#ifndef BOOST_NO_DELETED_FUNCTIONS
-// public:
-// recursive_timed_mutex(recursive_timed_mutex const&) = delete;
-// recursive_timed_mutex& operator=(recursive_timed_mutex const&) = delete;
-//#else // BOOST_NO_DELETED_FUNCTIONS
-// private:
-// recursive_timed_mutex(recursive_timed_mutex const&);
-// recursive_timed_mutex& operator=(recursive_timed_mutex const&);
-//#endif // BOOST_NO_DELETED_FUNCTIONS
     private:
         pthread_mutex_t m;
 #ifndef BOOST_USE_PTHREAD_RECURSIVE_TIMEDLOCK

Modified: trunk/boost/thread/pthread/shared_mutex.hpp
==============================================================================
--- trunk/boost/thread/pthread/shared_mutex.hpp (original)
+++ trunk/boost/thread/pthread/shared_mutex.hpp 2012-04-28 08:25:28 EDT (Sat, 28 Apr 2012)
@@ -17,6 +17,7 @@
 #include <boost/chrono/system_clocks.hpp>
 #include <boost/chrono/ceil.hpp>
 #endif
+#include <boost/thread/detail/delete.hpp>
 
 #include <boost/config/abi_prefix.hpp>
 
@@ -47,16 +48,6 @@
             shared_cond.notify_all();
         }
 
-
-//#ifndef BOOST_NO_DELETED_FUNCTIONS
-// public:
-// shared_mutex(shared_mutex const&) = delete;
-// shared_mutex& operator=(shared_mutex const&) = delete;
-//#else // BOOST_NO_DELETED_FUNCTIONS
-// private:
-// shared_mutex(shared_mutex const&);
-// shared_mutex& operator=(shared_mutex const&);
-//#endif // BOOST_NO_DELETED_FUNCTIONS
     public:
         BOOST_THREAD_NO_COPYABLE(shared_mutex)
 

Modified: trunk/boost/thread/reverse_lock.hpp
==============================================================================
--- trunk/boost/thread/reverse_lock.hpp (original)
+++ trunk/boost/thread/reverse_lock.hpp 2012-04-28 08:25:28 EDT (Sat, 28 Apr 2012)
@@ -7,6 +7,7 @@
 #define BOOST_THREAD_REVERSE_LOCK_HPP
 #include <boost/thread/detail/config.hpp>
 #include <boost/thread/locks.hpp>
+#include <boost/thread/detail/delete.hpp>
 
 namespace boost
 {
@@ -15,15 +16,6 @@
     class reverse_lock
     {
 
-//#ifndef BOOST_NO_DELETED_FUNCTIONS
-// public:
-// reverse_lock(reverse_lock const&) = delete;
-// reverse_lock& operator=(reverse_lock const&) = delete;
-//#else // BOOST_NO_DELETED_FUNCTIONS
-// private:
-// reverse_lock(reverse_lock&);
-// reverse_lock& operator=(reverse_lock&);
-//#endif // BOOST_NO_DELETED_FUNCTIONS
     public:
         typedef typename Lock::mutex_type mutex_type;
         BOOST_THREAD_NO_COPYABLE(reverse_lock)

Modified: trunk/boost/thread/shared_lock_guard.hpp
==============================================================================
--- trunk/boost/thread/shared_lock_guard.hpp (original)
+++ trunk/boost/thread/shared_lock_guard.hpp 2012-04-28 08:25:28 EDT (Sat, 28 Apr 2012)
@@ -7,6 +7,7 @@
 #define BOOST_THREAD_SHARED_LOCK_GUARD_HPP
 #include <boost/thread/detail/config.hpp>
 #include <boost/thread/locks.hpp>
+#include <boost/thread/detail/delete.hpp>
 
 namespace boost
 {
@@ -17,15 +18,6 @@
     private:
         SharedMutex& m;
 
-//#ifndef BOOST_NO_DELETED_FUNCTIONS
-// public:
-// shared_lock_guard(shared_lock_guard const&) = delete;
-// shared_lock_guard& operator=(shared_lock_guard const&) = delete;
-//#else // BOOST_NO_DELETED_FUNCTIONS
-// private:
-// shared_lock_guard(shared_lock_guard&);
-// shared_lock_guard& operator=(shared_lock_guard&);
-//#endif // BOOST_NO_DELETED_FUNCTIONS
     public:
         typedef SharedMutex mutex_type;
         BOOST_THREAD_NO_COPYABLE(shared_lock_guard)

Modified: trunk/libs/thread/test/test_6130.cpp
==============================================================================
--- trunk/libs/thread/test/test_6130.cpp (original)
+++ trunk/libs/thread/test/test_6130.cpp 2012-04-28 08:25:28 EDT (Sat, 28 Apr 2012)
@@ -5,26 +5,34 @@
 #if defined(BOOST_THREAD_PLATFORM_PTHREAD)
 #include <unistd.h>
 #endif
+
 boost::mutex mtx;
 boost::condition_variable cv;
 
+using namespace boost::posix_time;
+using namespace boost::gregorian;
 int main()
 {
 #if defined(BOOST_THREAD_PLATFORM_PTHREAD)
 
- for (int i=0; i<3; ++i) {
- const time_t wait_time = ::time(0)+1;
+ for (int i=0; i<3; ++i)
+ {
+ const time_t now_time = ::time(0);
+ const time_t wait_time = now_time+1;
+ time_t end_time;
+ assert(now_time < wait_time);
 
- boost::mutex::scoped_lock lk(mtx);
- //const bool res =
- (void)cv.timed_wait(lk, boost::posix_time::from_time_t(wait_time));
- const time_t end_time = ::time(0);
- std::cerr << "end_time=" << end_time << " \n";
- std::cerr << "wait_time=" << wait_time << " \n";
- std::cerr << end_time - wait_time << " \n";
- assert(end_time >= wait_time);
- std::cerr << " OK\n";
- }
+ boost::mutex::scoped_lock lk(mtx);
+ //const bool res =
+ (void)cv.timed_wait(lk, from_time_t(wait_time));
+ end_time = ::time(0);
+ std::cerr << "now_time =" << now_time << " \n";
+ std::cerr << "end_time =" << end_time << " \n";
+ std::cerr << "wait_time=" << wait_time << " \n";
+ std::cerr << end_time - wait_time << " \n";
+ assert(end_time >= wait_time);
+ std::cerr << " OK\n";
+ }
 #endif
- return 0;
+ 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