Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82624 - in trunk: boost/thread/detail boost/thread/pthread libs/thread/test/sync/mutual_exclusion/once/call_once
From: vicente.botet_at_[hidden]
Date: 2013-01-26 11:20:06


Author: viboes
Date: 2013-01-26 11:20:05 EST (Sat, 26 Jan 2013)
New Revision: 82624
URL: http://svn.boost.org/trac/boost/changeset/82624

Log:
Thread: Added two more test cases for call_once for thread I/F.
Text files modified:
   trunk/boost/thread/detail/invoke.hpp | 19 +++++++++++++++++++
   trunk/boost/thread/detail/thread.hpp | 2 +-
   trunk/boost/thread/pthread/once.hpp | 5 +++++
   trunk/boost/thread/pthread/once_atomic.hpp | 5 +++++
   trunk/libs/thread/test/sync/mutual_exclusion/once/call_once/call_once_pass.cpp | 14 ++++++++++++++
   5 files changed, 44 insertions(+), 1 deletions(-)

Modified: trunk/boost/thread/detail/invoke.hpp
==============================================================================
--- trunk/boost/thread/detail/invoke.hpp (original)
+++ trunk/boost/thread/detail/invoke.hpp 2013-01-26 11:20:05 EST (Sat, 26 Jan 2013)
@@ -18,6 +18,9 @@
 
 #include <boost/config.hpp>
 #include <boost/static_assert.hpp>
+#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL
+#include <functional>
+#endif
 
 namespace boost
 {
@@ -82,6 +85,22 @@
     {
       return boost::forward<Fp>(f)(boost::forward<Args>(args)...);
     }
+#else
+#if ! defined(BOOST_NO_SFINAE_EXPR) && \
+ ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
+ ! defined BOOST_NO_CXX11_HDR_FUNCTIONAL && \
+ ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+
+ template <class Ret, class Fp, class ...Args>
+ inline
+ Ret invoke(Fp&& f, Args&& ...args)
+ {
+ return std::bind(boost::forward<Fp>(f), boost::forward<Args>(args)...)();
+ }
+
+#define BOOST_THREAD_PROVIDES_INVOKE_RET
+
+#endif
 
 #endif
       }

Modified: trunk/boost/thread/detail/thread.hpp
==============================================================================
--- trunk/boost/thread/detail/thread.hpp (original)
+++ trunk/boost/thread/detail/thread.hpp 2013-01-26 11:20:05 EST (Sat, 26 Jan 2013)
@@ -725,7 +725,7 @@
         return const_cast<thread*>(this)->native_handle();
     #else
         detail::thread_data_ptr const local_thread_info=(get_thread_info)();
- return (local_thread_info? id(local_thread_info) id());
+ return (local_thread_info? id(local_thread_info) : id());
     #endif
     }
 

Modified: trunk/boost/thread/pthread/once.hpp
==============================================================================
--- trunk/boost/thread/pthread/once.hpp (original)
+++ trunk/boost/thread/pthread/once.hpp 2013-01-26 11:20:05 EST (Sat, 26 Jan 2013)
@@ -135,6 +135,11 @@
                         thread_detail::decay_copy(boost::forward<Function>(f)),
                         thread_detail::decay_copy(boost::forward<ArgTypes>(args))...
                         );
+#elif defined BOOST_THREAD_PROVIDES_INVOKE_RET
+ detail::invoke<void>(
+ thread_detail::decay_copy(boost::forward<Function>(f)),
+ thread_detail::decay_copy(boost::forward<ArgTypes>(args))...
+ );
 #else
                     boost::bind(
                         thread_detail::decay_copy(boost::forward<Function>(f)),

Modified: trunk/boost/thread/pthread/once_atomic.hpp
==============================================================================
--- trunk/boost/thread/pthread/once_atomic.hpp (original)
+++ trunk/boost/thread/pthread/once_atomic.hpp 2013-01-26 11:20:05 EST (Sat, 26 Jan 2013)
@@ -82,6 +82,11 @@
                         thread_detail::decay_copy(boost::forward<Function>(f)),
                         thread_detail::decay_copy(boost::forward<ArgTypes>(args))...
                         );
+#elif defined BOOST_THREAD_PROVIDES_INVOKE_RET
+ detail::invoke<void>(
+ thread_detail::decay_copy(boost::forward<Function>(f)),
+ thread_detail::decay_copy(boost::forward<ArgTypes>(args))...
+ );
 #else
                     boost::bind(
                         thread_detail::decay_copy(boost::forward<Function>(f)),

Modified: trunk/libs/thread/test/sync/mutual_exclusion/once/call_once/call_once_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/mutual_exclusion/once/call_once/call_once_pass.cpp (original)
+++ trunk/libs/thread/test/sync/mutual_exclusion/once/call_once/call_once_pass.cpp 2013-01-26 11:20:05 EST (Sat, 26 Jan 2013)
@@ -180,6 +180,12 @@
   void operator()(BOOST_THREAD_RV_REF(MoveOnly))
   {
   }
+ void operator()(int)
+ {
+ }
+ void operator()()
+ {
+ }
 };
 
 int main()
@@ -236,6 +242,14 @@
         t1.join();
         BOOST_TEST(init1_member::called == 1);
     }
+ {
+ boost::once_flag f BOOST_INIT_ONCE_INIT;
+ boost::call_once(f, MoveOnly());
+ }
+ {
+ boost::once_flag f BOOST_INIT_ONCE_INIT;
+ boost::call_once(f, MoveOnly(), 1);
+ }
 #endif // BOOST_THREAD_PLATFORM_PTHREAD
 #if defined BOOST_THREAD_PLATFORM_PTHREAD && defined BOOST_THREAD_PROVIDES_INVOKE
     {


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