|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r77946 - in trunk/boost/thread: . detail
From: vicente.botet_at_[hidden]
Date: 2012-04-13 05:39:19
Author: viboes
Date: 2012-04-13 05:39:17 EDT (Fri, 13 Apr 2012)
New Revision: 77946
URL: http://svn.boost.org/trac/boost/changeset/77946
Log:
Thread: Make use of the new macros to reduce the code duplication-IV
Text files modified:
trunk/boost/thread/detail/move.hpp | 17 ++++++++
trunk/boost/thread/detail/thread.hpp | 66 ++++++++++---------------------
trunk/boost/thread/future.hpp | 82 ++++++++++++++++++++--------------------
3 files changed, 80 insertions(+), 85 deletions(-)
Modified: trunk/boost/thread/detail/move.hpp
==============================================================================
--- trunk/boost/thread/detail/move.hpp (original)
+++ trunk/boost/thread/detail/move.hpp 2012-04-13 05:39:17 EDT (Fri, 13 Apr 2012)
@@ -12,6 +12,7 @@
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/remove_cv.hpp>
+#include <boost/type_traits/decay.hpp>
#endif
#include <boost/thread/detail/delete.hpp>
@@ -167,4 +168,20 @@
#define BOOST_THREAD_COPYABLE_AND_MOVABLE(TYPE) \
BOOST_THREAD_MOVABLE(TYPE) \
+
+
+#ifndef BOOST_NO_RVALUE_REFERENCES
+namespace boost
+{ namespace thread_detail
+ {
+ template <class T>
+ typename decay<T>::type
+ decay_copy(T&& t)
+ {
+ return boost::forward<T>(t);
+ }
+ }
+}
+#endif
+
#endif
Modified: trunk/boost/thread/detail/thread.hpp
==============================================================================
--- trunk/boost/thread/detail/thread.hpp (original)
+++ trunk/boost/thread/detail/thread.hpp 2012-04-13 05:39:17 EDT (Fri, 13 Apr 2012)
@@ -45,18 +45,6 @@
namespace boost
{
-#ifndef BOOST_NO_RVALUE_REFERENCES
- namespace thread_detail
- {
- template <class T>
- typename decay<T>::type
- decay_copy(T&& t)
- {
- return boost::forward<T>(t);
- }
- }
-#endif
-
namespace detail
{
template<typename F>
@@ -146,7 +134,7 @@
#ifndef BOOST_NO_RVALUE_REFERENCES
template<typename F>
- static inline detail::thread_data_ptr make_thread_info(F&& f)
+ static inline detail::thread_data_ptr make_thread_info(BOOST_THREAD_RV_REF(F) f)
{
return detail::thread_data_ptr(detail::heap_new<detail::thread_data<typename boost::remove_reference<F>::type> >(
boost::forward<F>(f)));
@@ -171,9 +159,11 @@
#endif
struct dummy;
public:
+#if 0 // This should not be needed anymore. Use instead BOOST_THREAD_MAKE_RV_REF.
#if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100)
thread(const volatile thread&);
#endif
+#endif
thread() BOOST_NOEXCEPT;
~thread()
{
@@ -189,7 +179,7 @@
template <
class F
>
- explicit thread(F&& f
+ explicit thread(BOOST_THREAD_RV_REF(F) f
, typename disable_if<is_same<typename decay<F>::type, thread>, dummy* >::type=0
):
thread_info(make_thread_info(thread_detail::decay_copy(boost::forward<F>(f))))
@@ -199,29 +189,12 @@
template <
class F
>
- thread(attributes& attrs, F&& f
- , typename disable_if<is_same<typename decay<F>::type, thread>, dummy* >::type=0
- ):
+ thread(attributes& attrs, BOOST_THREAD_RV_REF(F) f):
thread_info(make_thread_info(thread_detail::decay_copy(boost::forward<F>(f))))
{
start_thread(attrs);
}
- thread(thread&& other) BOOST_NOEXCEPT
- {
- thread_info.swap(other.thread_info);
- }
-
- thread& operator=(thread&& other) BOOST_NOEXCEPT
- {
-#if defined BOOST_THREAD_PROVIDES_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE
- if (joinable()) std::terminate();
-#endif
- thread_info=other.thread_info;
- other.thread_info.reset();
- return *this;
- }
-
#else
#ifdef BOOST_NO_SFINAE
template <class F>
@@ -238,21 +211,25 @@
}
#else
template <class F>
- explicit thread(F f,typename disable_if<boost::is_convertible<F&,BOOST_THREAD_RV_REF(F) >, dummy* >::type=0):
+ explicit thread(F f
+ // todo Disable also if Or is_same<typename decay<F>::type, thread>
+ , typename disable_if<boost::is_convertible<F&,BOOST_THREAD_RV_REF(F) >, dummy* >::type=0):
thread_info(make_thread_info(f))
{
start_thread();
}
template <class F>
- thread(attributes& attrs, F f,typename disable_if<boost::is_convertible<F&,BOOST_THREAD_RV_REF(F) >, dummy* >::type=0):
+ thread(attributes& attrs, F f
+ , typename disable_if<boost::is_convertible<F&,BOOST_THREAD_RV_REF(F) >, dummy* >::type=0):
thread_info(make_thread_info(f))
{
start_thread(attrs);
}
#endif
-
template <class F>
- explicit thread(BOOST_THREAD_RV_REF(F) f):
+ explicit thread(BOOST_THREAD_RV_REF(F) f
+ , typename disable_if<is_same<typename decay<F>::type, thread>, dummy* >::type=0
+ ):
thread_info(make_thread_info(f))
{
start_thread();
@@ -264,31 +241,32 @@
{
start_thread(attrs);
}
-
+#endif
thread(BOOST_THREAD_RV_REF(thread) x)
{
thread_info=BOOST_THREAD_RV(x).thread_info;
BOOST_THREAD_RV(x).thread_info.reset();
}
-
+#if 0 // This should not be needed anymore. Use instead BOOST_THREAD_MAKE_RV_REF.
#if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100)
thread& operator=(thread x)
{
swap(x);
return *this;
}
-#else
- thread& operator=(BOOST_THREAD_RV_REF(thread) x) BOOST_NOEXCEPT
+#endif
+#endif
+
+ thread& operator=(BOOST_THREAD_RV_REF(thread) other) BOOST_NOEXCEPT
{
+
#if defined BOOST_THREAD_PROVIDES_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE
if (joinable()) std::terminate();
#endif
- thread new_thread(x);
- swap(new_thread);
+ thread_info=BOOST_THREAD_RV(other).thread_info;
+ BOOST_THREAD_RV(other).thread_info.reset();
return *this;
}
-#endif
-#endif
template <class F,class A1>
thread(F f,A1 a1,typename disable_if<boost::is_convertible<F&,thread_attributes >, dummy* >::type=0):
Modified: trunk/boost/thread/future.hpp
==============================================================================
--- trunk/boost/thread/future.hpp (original)
+++ trunk/boost/thread/future.hpp 2012-04-13 05:39:17 EDT (Fri, 13 Apr 2012)
@@ -821,18 +821,18 @@
~BOOST_THREAD_FUTURE()
{}
-#ifndef BOOST_NO_RVALUE_REFERENCES
- BOOST_THREAD_FUTURE(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE) other) BOOST_NOEXCEPT
- {
- future_.swap(BOOST_THREAD_RV(other).future_);
- }
-#else
+//#ifndef BOOST_NO_RVALUE_REFERENCES
+// BOOST_THREAD_FUTURE(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE) other) BOOST_NOEXCEPT
+// {
+// future_.swap(BOOST_THREAD_RV(other).future_);
+// }
+//#else
BOOST_THREAD_FUTURE(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE) other) BOOST_NOEXCEPT:
future_(BOOST_THREAD_RV(other).future_)
{
BOOST_THREAD_RV(other).future_.reset();
}
-#endif
+//#endif
BOOST_THREAD_FUTURE& operator=(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE) other) BOOST_NOEXCEPT
{
future_=BOOST_THREAD_RV(other).future_;
@@ -979,16 +979,16 @@
future_=other.future_;
return *this;
}
-#ifndef BOOST_NO_RVALUE_REFERENCES
- shared_future(BOOST_THREAD_RV_REF(shared_future) other) BOOST_NOEXCEPT
- {
- future_.swap(BOOST_THREAD_RV(other).future_);
- }
- shared_future(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE<R>) other) BOOST_NOEXCEPT
- {
- future_.swap(BOOST_THREAD_RV(other).future_);
- }
-#else
+//#ifndef BOOST_NO_RVALUE_REFERENCES
+// shared_future(BOOST_THREAD_RV_REF(shared_future) other) BOOST_NOEXCEPT
+// {
+// future_.swap(BOOST_THREAD_RV(other).future_);
+// }
+// shared_future(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE<R>) other) BOOST_NOEXCEPT
+// {
+// future_.swap(BOOST_THREAD_RV(other).future_);
+// }
+//#else
shared_future(BOOST_THREAD_RV_REF(shared_future) other) BOOST_NOEXCEPT :
future_(BOOST_THREAD_RV(other).future_)
{
@@ -999,7 +999,7 @@
{
BOOST_THREAD_RV(other).future_.reset();
}
-#endif
+//#endif
shared_future& operator=(BOOST_THREAD_RV_REF(shared_future) other) BOOST_NOEXCEPT
{
future_.swap(BOOST_THREAD_RV(other).future_);
@@ -1167,28 +1167,28 @@
}
// Assignment
-#ifndef BOOST_NO_RVALUE_REFERENCES
- promise(BOOST_THREAD_RV_REF(promise) rhs) BOOST_NOEXCEPT:
- future_obtained(BOOST_THREAD_RV(rhs).future_obtained)
- {
- future_.swap(BOOST_THREAD_RV(rhs).future_);
- BOOST_THREAD_RV(rhs).future_.reset();
- BOOST_THREAD_RV(rhs).future_obtained=false;
- }
- promise & operator=(BOOST_THREAD_RV_REF(promise) rhs) BOOST_NOEXCEPT
- {
-#if defined BOOST_THREAD_PROMISE_LAZY
- future_.swap(BOOST_THREAD_RV(rhs).future_);
- future_obtained=BOOST_THREAD_RV(rhs).future_obtained;
- BOOST_THREAD_RV(rhs).future_.reset();
- BOOST_THREAD_RV(rhs).future_obtained=false;
-#else
- promise(boost::move(rhs)).swap(*this);
-#endif
-
- return *this;
- }
-#else
+//#ifndef BOOST_NO_RVALUE_REFERENCES
+// promise(BOOST_THREAD_RV_REF(promise) rhs) BOOST_NOEXCEPT:
+// future_obtained(BOOST_THREAD_RV(rhs).future_obtained)
+// {
+// future_.swap(BOOST_THREAD_RV(rhs).future_);
+// BOOST_THREAD_RV(rhs).future_.reset();
+// BOOST_THREAD_RV(rhs).future_obtained=false;
+// }
+// promise & operator=(BOOST_THREAD_RV_REF(promise) rhs) BOOST_NOEXCEPT
+// {
+//#if defined BOOST_THREAD_PROMISE_LAZY
+// future_.swap(BOOST_THREAD_RV(rhs).future_);
+// future_obtained=BOOST_THREAD_RV(rhs).future_obtained;
+// BOOST_THREAD_RV(rhs).future_.reset();
+// BOOST_THREAD_RV(rhs).future_obtained=false;
+//#else
+// promise(boost::move(rhs)).swap(*this);
+//#endif
+//
+// return *this;
+// }
+//#else
promise(BOOST_THREAD_RV_REF(promise) rhs) BOOST_NOEXCEPT :
future_(BOOST_THREAD_RV(rhs).future_),future_obtained(BOOST_THREAD_RV(rhs).future_obtained)
{
@@ -1203,7 +1203,7 @@
BOOST_THREAD_RV(rhs).future_obtained=false;
return *this;
}
-#endif
+//#endif
void swap(promise& other)
{
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