Boost logo

Boost-Commit :

From: anthony_at_[hidden]
Date: 2008-05-18 04:45:45


Author: anthonyw
Date: 2008-05-18 04:45:44 EDT (Sun, 18 May 2008)
New Revision: 45479
URL: http://svn.boost.org/trac/boost/changeset/45479

Log:
Added beginnings of real rvalue-reference support
Text files modified:
   trunk/boost/thread/win32/thread.hpp | 30 +++++++++++++++++++++++++++++-
   trunk/boost/thread/win32/thread_heap_alloc.hpp | 19 ++++++++++++++++++-
   2 files changed, 47 insertions(+), 2 deletions(-)

Modified: trunk/boost/thread/win32/thread.hpp
==============================================================================
--- trunk/boost/thread/win32/thread.hpp (original)
+++ trunk/boost/thread/win32/thread.hpp 2008-05-18 04:45:44 EDT (Sun, 18 May 2008)
@@ -174,13 +174,18 @@
         {
             F f;
 
+#ifdef BOOST_HAS_RVALUE_REFS
+ thread_data(F&& f_):
+ f(static_cast<F&&>(f_))
+ {}
+#else
             thread_data(F f_):
                 f(f_)
             {}
             thread_data(detail::thread_move_t<F> f_):
                 f(f_)
             {}
-
+#endif
             void run()
             {
                 f();
@@ -201,27 +206,50 @@
 
         detail::thread_data_ptr get_thread_info() const;
 
+#ifdef BOOST_HAS_RVALUE_REFS
+ template<typename F>
+ static inline detail::thread_data_ptr make_thread_info(F&& f)
+ {
+ return detail::heap_new<thread_data<F> >(static_cast<F&&>(f));
+ }
+#else
         template<typename F>
         static inline detail::thread_data_ptr make_thread_info(F f)
         {
             return detail::heap_new<thread_data<F> >(f);
         }
+ template<typename F>
+ static inline detail::thread_data_ptr make_thread_info(boost::detail::thread_move_t<F> f)
+ {
+ return detail::heap_new<thread_data<F> >(f);
+ }
+#endif
     public:
         thread();
         ~thread();
 
+#ifdef BOOST_HAS_RVALUE_REFS
+ template <class F>
+ thread(F&& f):
+ thread_info(make_thread_info(static_cast<F&&>(f)))
+ {
+ start_thread();
+ }
+#else
         template <class F>
         explicit thread(F f):
             thread_info(make_thread_info(f))
         {
             start_thread();
         }
+
         template <class F>
         thread(detail::thread_move_t<F> f):
             thread_info(make_thread_info(f))
         {
             start_thread();
         }
+#endif
 
         template <class F,class A1>
         thread(F f,A1 a1):

Modified: trunk/boost/thread/win32/thread_heap_alloc.hpp
==============================================================================
--- trunk/boost/thread/win32/thread_heap_alloc.hpp (original)
+++ trunk/boost/thread/win32/thread_heap_alloc.hpp 2008-05-18 04:45:44 EDT (Sun, 18 May 2008)
@@ -84,6 +84,23 @@
             }
         }
 
+#ifdef BOOST_HAS_RVALUE_REFS
+ template<typename T,typename A1>
+ T* heap_new(A1&& a1)
+ {
+ void* const heap_memory=allocate_raw_heap_memory(sizeof(T));
+ try
+ {
+ T* const data=new (heap_memory) T(static_cast<A1&&>(a1));
+ return data;
+ }
+ catch(...)
+ {
+ free_raw_heap_memory(heap_memory);
+ throw;
+ }
+ }
+#else
         template<typename T,typename A1>
         T* heap_new(A1 a1)
         {
@@ -99,7 +116,7 @@
                 throw;
             }
         }
-
+#endif
         template<typename T,typename A1,typename A2>
         T* heap_new(A1 a1,A2 a2)
         {


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