Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85726 - in trunk/boost/sync: . detail detail/darwin detail/generic detail/windows
From: andrey.semashev_at_[hidden]
Date: 2013-09-17 13:37:46


Author: andysem
Date: 2013-09-17 13:37:46 EDT (Tue, 17 Sep 2013)
New Revision: 85726
URL: http://svn.boost.org/trac/boost/changeset/85726

Log:
Fixed test compilation. Also fixed various bugs.

Text files modified:
   trunk/boost/sync/detail/config.hpp | 38 +++++++++++++++++++++++--
   trunk/boost/sync/detail/darwin/semaphore.hpp | 4 ++
   trunk/boost/sync/detail/generic/event_cv_emulation.hpp | 9 +++++
   trunk/boost/sync/detail/generic/semaphore.hpp | 5 +++
   trunk/boost/sync/detail/pthread.hpp | 23 ---------------
   trunk/boost/sync/detail/windows/event.hpp | 58 ++++++++++++++++++++++++++++-----------
   trunk/boost/sync/detail/windows/semaphore.hpp | 7 +++-
   trunk/boost/sync/event.hpp | 10 ++----
   8 files changed, 101 insertions(+), 53 deletions(-)

Modified: trunk/boost/sync/detail/config.hpp
==============================================================================
--- trunk/boost/sync/detail/config.hpp Tue Sep 17 12:55:51 2013 (r85725)
+++ trunk/boost/sync/detail/config.hpp 2013-09-17 13:37:46 EDT (Tue, 17 Sep 2013) (r85726)
@@ -30,16 +30,46 @@
 // By default use Windows 2000 API: _WIN32_WINNT_WIN2K
 #define BOOST_SYNC_USE_WINAPI_VERSION 0x0500
 #endif
-
 #endif
-#if defined(BOOST_SYNC_USE_PTHREAD)
-#define BOOST_SYNC_DETAIL_PLATFORM_PTHREAD
-#elif defined(BOOST_SYNC_USE_WINAPI_VERSION)
+
+#if defined(BOOST_SYNC_USE_WINAPI_VERSION) && !defined(BOOST_SYNC_USE_PTHREAD)
 #define BOOST_SYNC_DETAIL_PLATFORM_WINAPI
 #else
 #define BOOST_SYNC_DETAIL_PLATFORM_PTHREAD
 #endif
 
+#if defined(BOOST_SYNC_DETAIL_PLATFORM_PTHREAD)
+#define BOOST_SYNC_DETAIL_ABI_NAMESPACE posix
+#elif defined(BOOST_SYNC_DETAIL_PLATFORM_WINAPI)
+#if BOOST_SYNC_USE_WINAPI_VERSION >= 0x0600
+#define BOOST_SYNC_DETAIL_ABI_NAMESPACE winnt6
+#else
+#define BOOST_SYNC_DETAIL_ABI_NAMESPACE winnt5
+#endif
+#else
+#error Boost.Sync: Internal configuration error: unknown base threading API
+#endif
+
+#if !defined(BOOST_NO_CXX11_INLINE_NAMESPACES)
+#define BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE inline namespace BOOST_SYNC_DETAIL_ABI_NAMESPACE
+#else
+#define BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE namespace BOOST_SYNC_DETAIL_ABI_NAMESPACE
+namespace boost {
+namespace sync {
+
+// Emulate inline namespace with a using directive
+BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {}
+
+using namespace BOOST_SYNC_DETAIL_ABI_NAMESPACE
+#if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+__attribute__((__strong__))
+#endif
+;
+
+}
+}
+#endif // !defined(BOOST_NO_CXX11_INLINE_NAMESPACES)
+
 #if ! defined BOOST_SYNC_DONT_USE_CHRONO \
   && ! defined BOOST_SYNC_USES_CHRONO
 #define BOOST_SYNC_USES_CHRONO

Modified: trunk/boost/sync/detail/darwin/semaphore.hpp
==============================================================================
--- trunk/boost/sync/detail/darwin/semaphore.hpp Tue Sep 17 12:55:51 2013 (r85725)
+++ trunk/boost/sync/detail/darwin/semaphore.hpp 2013-09-17 13:37:46 EDT (Tue, 17 Sep 2013) (r85726)
@@ -32,6 +32,8 @@
 
 namespace sync {
 
+BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {
+
 class semaphore
 {
     BOOST_DELETED_FUNCTION(semaphore(semaphore const&))
@@ -110,6 +112,8 @@
     dispatch_semaphore_t m_sem;
 };
 
+} // namespace posix
+
 } // namespace sync
 
 } // namespace boost

Modified: trunk/boost/sync/detail/generic/event_cv_emulation.hpp
==============================================================================
--- trunk/boost/sync/detail/generic/event_cv_emulation.hpp Tue Sep 17 12:55:51 2013 (r85725)
+++ trunk/boost/sync/detail/generic/event_cv_emulation.hpp 2013-09-17 13:37:46 EDT (Tue, 17 Sep 2013) (r85726)
@@ -12,10 +12,14 @@
 #include <boost/thread/condition_variable.hpp>
 #include <boost/thread/mutex.hpp>
 
+#include <boost/sync/detail/config.hpp>
+#include <boost/sync/detail/header.hpp>
+
 #define BOOST_SYNC_EVENT_EMULATED
 
 namespace boost {
 namespace sync {
+BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {
 
 class event
 {
@@ -23,7 +27,7 @@
     BOOST_DELETED_FUNCTION(event& operator=(event const&));
 
 public:
- event(bool auto_reset = false):
+ explicit event(bool auto_reset = false):
         auto_reset_(auto_reset), set_(false)
     {}
 
@@ -111,5 +115,8 @@
 
 }
 }
+}
+
+#include <boost/sync/detail/footer.hpp>
 
 #endif // BOOST_SYNC_DETAIL_GENERIC_EVENT_CV_EMULATION_HPP

Modified: trunk/boost/sync/detail/generic/semaphore.hpp
==============================================================================
--- trunk/boost/sync/detail/generic/semaphore.hpp Tue Sep 17 12:55:51 2013 (r85725)
+++ trunk/boost/sync/detail/generic/semaphore.hpp 2013-09-17 13:37:46 EDT (Tue, 17 Sep 2013) (r85726)
@@ -30,8 +30,11 @@
 #define BOOST_SYNC_SEMAPHORE_EMULATED
 
 namespace boost {
+
 namespace sync {
 
+BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {
+
 class semaphore
 {
     BOOST_DELETED_FUNCTION(semaphore(semaphore const&))
@@ -95,6 +98,8 @@
     boost::condition_variable m_cond;
 };
 
+} // namespace
+
 } // namespace sync
 
 } // namespace boost

Modified: trunk/boost/sync/detail/pthread.hpp
==============================================================================
--- trunk/boost/sync/detail/pthread.hpp Tue Sep 17 12:55:51 2013 (r85725)
+++ trunk/boost/sync/detail/pthread.hpp 2013-09-17 13:37:46 EDT (Tue, 17 Sep 2013) (r85726)
@@ -35,33 +35,10 @@
 #endif
 #endif
 
-// ABI namespace name
-#define BOOST_SYNC_DETAIL_ABI_NAMESPACE posix
-
-#if !defined(BOOST_NO_CXX11_INLINE_NAMESPACES)
-#define BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE inline namespace BOOST_SYNC_DETAIL_ABI_NAMESPACE
-#else
-#define BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE namespace BOOST_SYNC_DETAIL_ABI_NAMESPACE
-#endif // !defined(BOOST_NO_CXX11_INLINE_NAMESPACES)
-
 namespace boost {
 
 namespace sync {
 
-#if defined(BOOST_NO_CXX11_INLINE_NAMESPACES)
-
-// Emulate inline namespace with a using directive
-
-BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {}
-
-using namespace BOOST_SYNC_DETAIL_ABI_NAMESPACE
-#if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-__attribute__((__strong__))
-#endif
-;
-
-#endif // defined(BOOST_NO_CXX11_INLINE_NAMESPACES)
-
 namespace detail {
 
 namespace posix {

Modified: trunk/boost/sync/detail/windows/event.hpp
==============================================================================
--- trunk/boost/sync/detail/windows/event.hpp Tue Sep 17 12:55:51 2013 (r85725)
+++ trunk/boost/sync/detail/windows/event.hpp 2013-09-17 13:37:46 EDT (Tue, 17 Sep 2013) (r85726)
@@ -9,17 +9,23 @@
 #ifndef BOOST_SYNC_EVENT_DETAIL_WINDOWS_EVENT_HPP
 #define BOOST_SYNC_EVENT_DETAIL_WINDOWS_EVENT_HPP
 
+#include <cstddef>
+#include <boost/assert.hpp>
+#include <boost/throw_exception.hpp>
 #include <boost/detail/win/GetLastError.hpp>
 #include <boost/detail/win/synchronization.hpp>
 #include <boost/detail/win/handles.hpp>
 
+#include <boost/sync/detail/config.hpp>
 #include <boost/sync/exceptions/resource_error.hpp>
-
-#include <boost/typeof/typeof.hpp>
+#include <boost/sync/detail/header.hpp>
 
 namespace boost {
+
 namespace sync {
 
+BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {
+
 class event
 {
     BOOST_DELETED_FUNCTION(event(event const&))
@@ -27,13 +33,17 @@
 
     typedef boost::detail::win32::HANDLE_ HANDLE_;
     typedef boost::detail::win32::BOOL_ BOOL_;
+ typedef boost::detail::win32::DWORD_ DWORD_;
 
 public:
- event(bool auto_reset = false)
+ explicit event(bool auto_reset = false)
     {
         handle_ = boost::detail::win32::CreateEventA(NULL, !auto_reset, 0, NULL);
         if (!handle_)
- boost::throw_exception(thread_resource_error(boost::detail::win32::GetLastError(), "boost::sync::event constructor failed in CreateEvent"));
+ {
+ const DWORD_ err = boost::detail::win32::GetLastError();
+ BOOST_THROW_EXCEPTION(resource_error(err, "boost::sync::event constructor failed in CreateEvent"));
+ }
     }
 
     ~event()
@@ -45,14 +55,20 @@
     {
         const BOOL_ status = boost::detail::win32::SetEvent(handle_);
         if (status == 0)
- boost::throw_exception(thread_resource_error(boost::detail::win32::GetLastError(), "boost::sync::event::post failed in ReleaseEvent"));
+ {
+ const DWORD_ err = boost::detail::win32::GetLastError();
+ BOOST_THROW_EXCEPTION(resource_error(err, "boost::sync::event::post failed in ReleaseEvent"));
+ }
     }
 
     void reset()
     {
         const BOOL_ status = boost::detail::win32::ResetEvent(handle_);
         if (status == 0)
- boost::throw_exception(thread_resource_error(boost::detail::win32::GetLastError(), "boost::sync::event::reset failed in ResetEvent"));
+ {
+ const DWORD_ err = boost::detail::win32::GetLastError();
+ BOOST_THROW_EXCEPTION(resource_error(err, "boost::sync::event::reset failed in ResetEvent"));
+ }
     }
 
     bool wait()
@@ -61,11 +77,14 @@
 
         switch ( WaitForSingleObject(handle_, infinite) )
         {
- case WAIT_OBJECT_0:
+ case wait_object_0:
             return true;
 
- case WAIT_FAILED:
- boost::throw_exception(thread_resource_error(boost::detail::win32::GetLastError(), "boost::sync::event::wait failed in WaitForSingleObject"));
+ case wait_failed:
+ {
+ const DWORD_ err = boost::detail::win32::GetLastError();
+ BOOST_THROW_EXCEPTION(resource_error(err, "boost::sync::event::wait failed in WaitForSingleObject"));
+ }
 
         default:
             BOOST_ASSERT(false);
@@ -75,14 +94,13 @@
 
     bool try_wait()
     {
- return do_try_wait_for( 0L );
+ return do_try_wait_for( 0 );
     }
 
     template <class Rep, class Period>
     bool try_wait_for(const chrono::duration<Rep, Period> & rel_time)
     {
- BOOST_AUTO ( milliseconds, (DWORD_)chrono::duration_cast<chrono::milliseconds>( rel_time ) );
- return do_try_wait_for( milliseconds.count() );
+ return do_try_wait_for(static_cast< DWORD_ >(chrono::duration_cast<chrono::milliseconds>( rel_time ).count()));
     }
 
     template <class Clock, class Duration>
@@ -93,20 +111,23 @@
     }
 
 private:
- bool do_try_wait_for( long milliseconds )
+ bool do_try_wait_for( DWORD_ milliseconds )
     {
         using namespace boost::detail::win32;
 
         switch ( WaitForSingleObject(handle_, milliseconds) )
         {
- case WAIT_OBJECT_0:
+ case wait_object_0:
             return true;
 
- case WAIT_TIMEOUT:
+ case wait_timeout:
             return false;
 
- case WAIT_FAILED:
- boost::throw_exception(thread_resource_error(boost::detail::win32::GetLastError(), "boost::sync::event::do_try_wait_for failed in WaitForSingleObject"));
+ case wait_failed:
+ {
+ const DWORD_ err = boost::detail::win32::GetLastError();
+ BOOST_THROW_EXCEPTION(resource_error(err, "boost::sync::event::do_try_wait_for failed in WaitForSingleObject"));
+ }
 
         default:
             BOOST_ASSERT(false);
@@ -119,5 +140,8 @@
 
 }
 }
+}
+
+#include <boost/sync/detail/footer.hpp>
 
 #endif // BOOST_SYNC_EVENT_DETAIL_WINDOWS_EVENT_HPP

Modified: trunk/boost/sync/detail/windows/semaphore.hpp
==============================================================================
--- trunk/boost/sync/detail/windows/semaphore.hpp Tue Sep 17 12:55:51 2013 (r85725)
+++ trunk/boost/sync/detail/windows/semaphore.hpp 2013-09-17 13:37:46 EDT (Tue, 17 Sep 2013) (r85726)
@@ -27,6 +27,8 @@
 
 namespace sync {
 
+BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {
+
 class semaphore
 {
     BOOST_DELETED_FUNCTION(semaphore(semaphore const&))
@@ -93,8 +95,7 @@
     template <class Rep, class Period>
     bool try_wait_for(const chrono::duration<Rep, Period> & rel_time)
     {
- BOOST_AUTO ( milliseconds, (DWORD_)chrono::duration_cast<chrono::milliseconds>( rel_time ) );
- return do_try_wait_for( milliseconds.count() );
+ return do_try_wait_for(static_cast< DWORD_ >(chrono::duration_cast<chrono::milliseconds>( rel_time ).count()));
     }
 
     template <class Clock, class Duration>
@@ -133,6 +134,8 @@
     HANDLE_ m_sem;
 };
 
+} // namespace winnt
+
 } // namespace sync
 
 } // namespace boost

Modified: trunk/boost/sync/event.hpp
==============================================================================
--- trunk/boost/sync/event.hpp Tue Sep 17 12:55:51 2013 (r85725)
+++ trunk/boost/sync/event.hpp 2013-09-17 13:37:46 EDT (Tue, 17 Sep 2013) (r85726)
@@ -20,7 +20,10 @@
      *
      * \b Throws: if an error occurs.
      */
- event(bool auto_reset = false);
+ explicit event(bool auto_reset = false);
+
+ event(event const&) = delete;
+ event& operator= (event const&) = delete;
 
     /**
      * \b Effects: Destroys the event object.
@@ -94,9 +97,6 @@
 #pragma once
 #endif
 
-#include <boost/sync/detail/header.hpp>
-
-
 #if defined(BOOST_SYNC_DETAIL_PLATFORM_WINAPI)
 #include <boost/sync/detail/windows/event.hpp>
 
@@ -112,8 +112,6 @@
 
 #endif
 
-#include <boost/sync/detail/footer.hpp>
-
 #endif // BOOST_SYNC_DETAIL_DOXYGEN
 
 #endif // BOOST_SYNC_EVENT_HPP


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