Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86351 - in trunk: boost/sync boost/sync/condition_variables boost/sync/detail boost/sync/detail/condition_variables boost/sync/detail/event boost/sync/detail/events boost/sync/detail/semaphore boost/sync/events boost/sync/mutexes libs/sync/test/run
From: andrey.semashev_at_[hidden]
Date: 2013-10-18 10:00:03


Author: andysem
Date: 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013)
New Revision: 86351
URL: http://svn.boost.org/trac/boost/changeset/86351

Log:
Events separated into different headers and ported to the time units abstraction layer.

Added:
   trunk/boost/sync/detail/events/
      - copied from r86335, trunk/boost/sync/detail/event/
   trunk/boost/sync/detail/events/auto_reset_event_emulation.hpp
      - copied, changed from r86335, trunk/boost/sync/detail/event/event_emulation.hpp
   trunk/boost/sync/detail/events/auto_reset_event_futex.hpp
      - copied, changed from r86335, trunk/boost/sync/detail/event/event_futex.hpp
   trunk/boost/sync/detail/events/auto_reset_event_semaphore.hpp
      - copied, changed from r86335, trunk/boost/sync/detail/event/event_autoreset_semaphore.hpp
   trunk/boost/sync/detail/events/auto_reset_event_windows.hpp (contents, props changed)
   trunk/boost/sync/detail/events/basic_event_windows.hpp
      - copied, changed from r86335, trunk/boost/sync/detail/event/event_windows.hpp
   trunk/boost/sync/detail/events/manual_reset_event_emulation.hpp (contents, props changed)
   trunk/boost/sync/detail/events/manual_reset_event_futex.hpp (contents, props changed)
   trunk/boost/sync/detail/events/manual_reset_event_mach.hpp
      - copied, changed from r86335, trunk/boost/sync/detail/event/event_mach.hpp
   trunk/boost/sync/detail/events/manual_reset_event_windows.hpp (contents, props changed)
   trunk/boost/sync/detail/semaphore/basic_semaphore_mach.hpp (contents, props changed)
   trunk/boost/sync/detail/semaphore_config.hpp (contents, props changed)
   trunk/boost/sync/events/
   trunk/boost/sync/events.hpp
      - copied, changed from r86335, trunk/boost/sync/event.hpp
   trunk/boost/sync/events/auto_reset_event.hpp (contents, props changed)
   trunk/boost/sync/events/manual_reset_event.hpp (contents, props changed)
Deleted:
   trunk/boost/sync/detail/event/
   trunk/boost/sync/detail/events/event_autoreset_semaphore.hpp
   trunk/boost/sync/detail/events/event_emulation.hpp
   trunk/boost/sync/detail/events/event_futex.hpp
   trunk/boost/sync/detail/events/event_mach.hpp
   trunk/boost/sync/detail/events/event_windows.hpp
   trunk/boost/sync/event.hpp
Text files modified:
   trunk/boost/sync/condition_variables/condition_variable.hpp | 6
   trunk/boost/sync/detail/condition_variables/basic_condition_variable_windows.hpp | 6
   trunk/boost/sync/detail/config.hpp | 39 +++-
   trunk/boost/sync/detail/events/auto_reset_event_emulation.hpp | 180 +++++-----------------
   trunk/boost/sync/detail/events/auto_reset_event_futex.hpp | 148 +++++------------
   trunk/boost/sync/detail/events/auto_reset_event_semaphore.hpp | 42 ++--
   trunk/boost/sync/detail/events/auto_reset_event_windows.hpp | 73 +++++++++
   trunk/boost/sync/detail/events/basic_event_windows.hpp | 218 +++++++++++++++------------
   /dev/null | 120 ---------------
   /dev/null | 209 --------------------------
   /dev/null | 315 ----------------------------------------
   /dev/null | 124 ---------------
   /dev/null | 181 ----------------------
   trunk/boost/sync/detail/events/manual_reset_event_emulation.hpp | 209 ++++++++++++++++++++++++++
   trunk/boost/sync/detail/events/manual_reset_event_futex.hpp | 209 ++++++++++++++++++++++++++
   trunk/boost/sync/detail/events/manual_reset_event_mach.hpp | 104 +++++--------
   trunk/boost/sync/detail/events/manual_reset_event_windows.hpp | 74 +++++++++
   trunk/boost/sync/detail/semaphore/basic_semaphore_mach.hpp | 183 +++++++++++++++++++++++
   trunk/boost/sync/detail/semaphore/semaphore_emulation.hpp | 4
   trunk/boost/sync/detail/semaphore/semaphore_mach.hpp | 140 +----------------
   trunk/boost/sync/detail/semaphore/semaphore_windows.hpp | 13 +
   trunk/boost/sync/detail/semaphore_config.hpp | 46 +++++
   trunk/boost/sync/detail/time_units.hpp | 114 +++++++-------
   /dev/null | 215 ---------------------------
   trunk/boost/sync/events.hpp | 223 ++--------------------------
   trunk/boost/sync/events/auto_reset_event.hpp | 156 +++++++++++++++++++
   trunk/boost/sync/events/manual_reset_event.hpp | 163 ++++++++++++++++++++
   trunk/boost/sync/mutexes/mutex.hpp | 6
   trunk/boost/sync/mutexes/timed_mutex.hpp | 6
   trunk/boost/sync/semaphore.hpp | 122 +++++++-------
   trunk/libs/sync/test/run/event_test.cpp | 37 +++-
   31 files changed, 1600 insertions(+), 2085 deletions(-)

Modified: trunk/boost/sync/condition_variables/condition_variable.hpp
==============================================================================
--- trunk/boost/sync/condition_variables/condition_variable.hpp Fri Oct 18 07:40:46 2013 (r86350)
+++ trunk/boost/sync/condition_variables/condition_variable.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -275,12 +275,10 @@
 #pragma once
 #endif
 
-#if defined(BOOST_SYNC_DETAIL_PLATFORM_PTHREAD)
-#include <boost/sync/detail/condition_variables/condition_variable_posix.hpp>
-#elif defined(BOOST_SYNC_DETAIL_PLATFORM_WINAPI)
+#if defined(BOOST_SYNC_DETAIL_PLATFORM_WINAPI)
 #include <boost/sync/detail/condition_variables/condition_variable_windows.hpp>
 #else
-#error Boost.Sync: Unsupported threading API
+#include <boost/sync/detail/condition_variables/condition_variable_posix.hpp>
 #endif
 
 #endif // defined(BOOST_SYNC_DETAIL_DOXYGEN)

Modified: trunk/boost/sync/detail/condition_variables/basic_condition_variable_windows.hpp
==============================================================================
--- trunk/boost/sync/detail/condition_variables/basic_condition_variable_windows.hpp Fri Oct 18 07:40:46 2013 (r86350)
+++ trunk/boost/sync/detail/condition_variables/basic_condition_variable_windows.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -321,7 +321,7 @@
         while (true)
         {
             const boost::detail::winapi::DWORD_ res = boost::detail::winapi::WaitForSingleObject(state->m_semaphore, boost::detail::winapi::infinite);
- if (res != boost::detail::winapi::wait_object_0)
+ if (BOOST_UNLIKELY(res != boost::detail::winapi::wait_object_0))
             {
                 const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError();
                 {
@@ -382,7 +382,7 @@
                             --state->m_notify_count;
                         interlocked_write_release(&m_total_waiter_count, m_total_waiter_count - 1);
                     }
- BOOST_SYNC_DETAIL_THROW(wait_error, (err)("condition_variable wait failed in WaitForSingleObject"));
+ BOOST_SYNC_DETAIL_THROW(wait_error, (err)("condition_variable timed_wait failed in WaitForSingleObject"));
                 }
             }
         }
@@ -407,7 +407,7 @@
         while (true)
         {
             const boost::detail::winapi::DWORD_ res = boost::detail::winapi::WaitForMultipleObjects(sizeof(handles) / sizeof(*handles), handles, false, boost::detail::winapi::infinite);
- if (res == boost::detail::winapi::wait_failed)
+ if (BOOST_UNLIKELY(res == boost::detail::winapi::wait_failed))
             {
                 const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError();
                 {

Modified: trunk/boost/sync/detail/config.hpp
==============================================================================
--- trunk/boost/sync/detail/config.hpp Fri Oct 18 07:40:46 2013 (r86350)
+++ trunk/boost/sync/detail/config.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -18,29 +18,47 @@
 
 #include <boost/config.hpp>
 
-#if defined(BOOST_WINDOWS)
-#include <boost/detail/winapi/config.hpp>
-#endif
-
 #ifdef BOOST_HAS_PRAGMA_ONCE
 #pragma once
 #endif
 
 // BOOST_SYNC_USE_PTHREAD is a user-configurable macro
-#if defined(BOOST_WINDOWS) && !defined(BOOST_SYNC_USE_PTHREAD)
+#if defined(BOOST_SYNC_USE_PTHREAD)
+
+#define BOOST_SYNC_DETAIL_PLATFORM_POSIX
+
+#elif defined(BOOST_WINDOWS)
+
+#include <boost/detail/winapi/config.hpp>
 #define BOOST_SYNC_DETAIL_PLATFORM_WINAPI
+
+#elif defined(__linux__) || defined(__linux) || defined(linux)
+
+#define BOOST_SYNC_DETAIL_PLATFORM_LINUX
+
+#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
+
+#include <Availability.h>
+#define BOOST_SYNC_DETAIL_PLATFORM_MACH
+
 #else
-#define BOOST_SYNC_DETAIL_PLATFORM_PTHREAD
+
+#define BOOST_SYNC_DETAIL_PLATFORM_POSIX
+
 #endif
 
-#if defined(BOOST_SYNC_DETAIL_PLATFORM_PTHREAD)
+#if defined(BOOST_SYNC_DETAIL_PLATFORM_POSIX)
 #define BOOST_SYNC_DETAIL_ABI_NAMESPACE posix
+#elif defined(BOOST_SYNC_DETAIL_PLATFORM_LINUX)
+#define BOOST_SYNC_DETAIL_ABI_NAMESPACE linux_
 #elif defined(BOOST_SYNC_DETAIL_PLATFORM_WINAPI)
 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
 #define BOOST_SYNC_DETAIL_ABI_NAMESPACE winnt6
 #else
 #define BOOST_SYNC_DETAIL_ABI_NAMESPACE winnt5
 #endif
+#elif defined(BOOST_SYNC_DETAIL_PLATFORM_MACH)
+#define BOOST_SYNC_DETAIL_ABI_NAMESPACE mach
 #else
 #error Boost.Sync: Internal configuration error: unknown base threading API
 #endif
@@ -65,11 +83,4 @@
 }
 #endif // !defined(BOOST_NO_CXX11_INLINE_NAMESPACES)
 
-#if ! defined BOOST_SYNC_DONT_USE_CHRONO \
- && ! defined BOOST_SYNC_USES_CHRONO
-#define BOOST_SYNC_USES_CHRONO
-#endif
-
-#define BOOST_SYNC_USES_CHRONO
-
 #endif // BOOST_SYNC_DETAIL_CONFIG_HPP_INCLUDED_

Copied and modified: trunk/boost/sync/detail/events/auto_reset_event_emulation.hpp (from r86335, trunk/boost/sync/detail/event/event_emulation.hpp)
==============================================================================
--- trunk/boost/sync/detail/event/event_emulation.hpp Wed Oct 16 13:49:10 2013 (r86335, copy source)
+++ trunk/boost/sync/detail/events/auto_reset_event_emulation.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -1,39 +1,35 @@
 // event.hpp, condition variable emulation
 //
 // Copyright (C) 2013 Tim Blechmann
+// Copyright (C) 2013 Andrey Semashev
 //
 // Distributed under the Boost Software License, Version 1.0. (See
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#ifndef BOOST_SYNC_DETAIL_EVENT_EVENT_EMULATION_HPP_INCLUDED_
-#define BOOST_SYNC_DETAIL_EVENT_EVENT_EMULATION_HPP_INCLUDED_
-
-#include <boost/sync/semaphore.hpp>
-
-// we use the semaphore implementation if we have native semaphores
-#ifndef BOOST_SYNC_SEMAPHORE_EMULATED
-#include <boost/sync/detail/event/event_autoreset_semaphore.hpp>
-#endif
-
-
-#include <boost/thread/condition_variable.hpp>
-#include <boost/thread/shared_mutex.hpp>
-#include <boost/thread/locks.hpp>
+#ifndef BOOST_SYNC_DETAIL_EVENTS_AUTO_RESET_EVENT_EMULATION_HPP_INCLUDED_
+#define BOOST_SYNC_DETAIL_EVENTS_AUTO_RESET_EVENT_EMULATION_HPP_INCLUDED_
 
+#include <boost/utility/enable_if.hpp>
 #include <boost/sync/detail/config.hpp>
-//#include <boost/sync/locks/lock_guard.hpp>
-//#include <boost/sync/locks/unique_lock.hpp>
+#include <boost/sync/detail/time_traits.hpp>
+#include <boost/sync/locks/lock_guard.hpp>
+#include <boost/sync/locks/unique_lock.hpp>
+#include <boost/sync/mutexes/mutex.hpp>
+#include <boost/sync/condition_variables/condition_variable.hpp>
 #include <boost/sync/detail/header.hpp>
 
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
 #define BOOST_SYNC_EVENT_EMULATED
 
 namespace boost {
-namespace sync {
-BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {
 
+namespace sync {
 
-#ifdef BOOST_SYNC_SEMAPHORE_EMULATED
+BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {
 
 class auto_reset_event
 {
@@ -41,13 +37,13 @@
     BOOST_DELETED_FUNCTION(auto_reset_event& operator=(auto_reset_event const&));
 
 public:
- auto_reset_event() BOOST_NOEXCEPT :
- m_is_set(false)
- {}
+ auto_reset_event() BOOST_NOEXCEPT : m_is_set(false)
+ {
+ }
 
     void post()
     {
- unique_lock<upgrade_mutex> lock(m_mutex);
+ sync::lock_guard< sync::mutex > lock(m_mutex);
         bool already_signaled = m_is_set;
         m_is_set = true;
         if (!already_signaled)
@@ -56,154 +52,66 @@
 
     void wait()
     {
- upgrade_lock<upgrade_mutex> lock(m_mutex);
+ sync::unique_lock< sync::mutex > lock(m_mutex);
 
         while (!m_is_set)
             m_cond.wait(lock);
 
- upgrade_to_unique_lock<upgrade_mutex> unique_lock(lock);
- m_is_set = false;
- }
-
- void reset()
- {
- lock_guard<upgrade_mutex> lock(m_mutex);
         m_is_set = false;
     }
 
     bool try_wait()
     {
- lock_guard<upgrade_mutex> lock(m_mutex);
+ sync::lock_guard< sync::mutex > lock(m_mutex);
         const bool res = m_is_set;
         if (res)
             m_is_set = false;
         return res;
     }
 
- template <class Duration>
- bool try_wait_for(const Duration & duration)
+ template< typename Time >
+ typename enable_if_c< sync::detail::time_traits< Time >::is_specialized, bool >::type timed_wait(Time const& timeout)
     {
- upgrade_lock<upgrade_mutex> lock(m_mutex);
-
- while (!m_is_set) {
- if (m_cond.wait_for(lock, duration) == cv_status::timeout) {
+ sync::unique_lock< sync::mutex > lock(m_mutex);
+ while (!m_is_set)
+ {
+ if (!m_cond.timed_wait(lock, timeout))
+ {
                 if (!m_is_set)
                     return false;
- break;
+ else
+ break;
             }
         }
 
- upgrade_to_unique_lock<upgrade_mutex> unique_lock(lock);
         m_is_set = false;
         return true;
     }
 
- template <typename TimePoint>
- bool try_wait_until(const TimePoint & timeout)
+ template< typename Duration >
+ typename enable_if< detail::is_time_tag_of< Duration, detail::time_duration_tag >, bool >::type wait_for(Duration const& duration)
     {
- upgrade_lock<upgrade_mutex> lock(m_mutex);
-
- while (!m_is_set) {
- if (m_cond.wait_until(lock, timeout) == cv_status::timeout) {
- if (!m_is_set)
- return false;
- break;
- }
- }
-
- upgrade_to_unique_lock<upgrade_mutex> unique_lock(lock);
- m_is_set = false;
- return true;
+ return timed_wait(duration);
     }
 
-private:
- bool m_is_set;
- upgrade_mutex m_mutex;
- condition_variable_any m_cond;
-};
-
-#endif
-
-class manual_reset_event
-{
- BOOST_DELETED_FUNCTION(manual_reset_event(manual_reset_event const&));
- BOOST_DELETED_FUNCTION(manual_reset_event& operator=(manual_reset_event const&));
-
-public:
- manual_reset_event() BOOST_NOEXCEPT :
- m_is_set(false)
- {}
-
- void post()
+ template< typename TimePoint >
+ typename enable_if< detail::is_time_tag_of< TimePoint, detail::time_point_tag >, bool >::type wait_until(TimePoint const& abs_time)
     {
- unique_lock<upgrade_mutex> lock(m_mutex);
- bool already_signaled = m_is_set;
- m_is_set = true;
- m_cond.notify_all();
- }
-
- void wait()
- {
- upgrade_lock<upgrade_mutex> lock(m_mutex);
-
- while (!m_is_set)
- m_cond.wait(lock);
- }
-
- void reset()
- {
- lock_guard<upgrade_mutex> lock(m_mutex);
- m_is_set = false;
- }
-
- bool try_wait()
- {
- lock_guard<upgrade_mutex> lock(m_mutex);
- return m_is_set;
- }
-
- template <typename Duration>
- bool try_wait_for(const Duration & duration)
- {
- upgrade_lock<upgrade_mutex> lock(m_mutex);
-
- while (!m_is_set) {
- if (m_cond.wait_for(lock, duration) == cv_status::timeout) {
- if (!m_is_set)
- return false;
- break;
- }
- }
-
- return true;
- }
-
- template <typename TimePoint>
- bool try_wait_until(const TimePoint & timeout)
- {
- upgrade_lock<upgrade_mutex> lock(m_mutex);
-
- while (!m_is_set) {
- if (m_cond.wait_until(lock, timeout) == cv_status::timeout) {
- if (!m_is_set)
- return false;
- break;
- }
- }
-
- return true;
+ return timed_wait(abs_time);
     }
 
 private:
+ sync::mutex m_mutex;
+ sync::condition_variable m_cond;
     bool m_is_set;
- upgrade_mutex m_mutex;
- condition_variable_any m_cond;
 };
 
-}
-}
-}
+} // namespace abi
+
+} // namespace sync
+
+} // namespace boost
 
 #include <boost/sync/detail/footer.hpp>
 
-#endif // BOOST_SYNC_DETAIL_EVENT_EVENT_EMULATION_HPP_INCLUDED_
+#endif // BOOST_SYNC_DETAIL_EVENTS_AUTO_RESET_EVENT_EMULATION_HPP_INCLUDED_

Copied and modified: trunk/boost/sync/detail/events/auto_reset_event_futex.hpp (from r86335, trunk/boost/sync/detail/event/event_futex.hpp)
==============================================================================
--- trunk/boost/sync/detail/event/event_futex.hpp Wed Oct 16 13:49:10 2013 (r86335, copy source)
+++ trunk/boost/sync/detail/events/auto_reset_event_futex.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -1,4 +1,4 @@
-// event.hpp, futex-based event
+// auto_reset_event_futex.hpp, futex-based event
 //
 // Copyright (C) 2013 Tim Blechmann
 // Copyright (C) 2013 Andrey Semashev
@@ -7,23 +7,31 @@
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#ifndef BOOST_SYNC_DETAIL_EVENT_EVENT_FUTEX_HPP_INCLUDED_
-#define BOOST_SYNC_DETAIL_EVENT_EVENT_FUTEX_HPP_INCLUDED_
+#ifndef BOOST_SYNC_DETAIL_EVENTS_AUTO_RESET_EVENT_FUTEX_HPP_INCLUDED_
+#define BOOST_SYNC_DETAIL_EVENTS_AUTO_RESET_EVENT_FUTEX_HPP_INCLUDED_
 
 #include <errno.h>
 #include <sys/time.h>
 
 #include <boost/assert.hpp>
 #include <boost/static_assert.hpp>
+#include <boost/utility/enable_if.hpp>
 #include <boost/sync/detail/config.hpp>
 #include <boost/sync/detail/atomic.hpp>
 #include <boost/sync/detail/pause.hpp>
 #include <boost/sync/detail/futex.hpp>
-
+#include <boost/sync/detail/time_traits.hpp>
+#include <boost/sync/detail/time_units.hpp>
 #include <boost/sync/detail/header.hpp>
 
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
 namespace boost {
+
 namespace sync {
+
 BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {
 
 class auto_reset_event
@@ -128,21 +136,26 @@
         return false;
     }
 
- template <typename Duration>
- bool try_wait_for(const Duration & duration) BOOST_NOEXCEPT
+ template< typename Time >
+ typename enable_if_c< sync::detail::time_traits< Time >::is_specialized, bool >::type timed_wait(Time const& timeout)
+ {
+ return priv_timed_wait(sync::detail::time_traits< Time >::to_sync_unit(timeout));
+ }
+
+ template< typename Duration >
+ typename enable_if< detail::is_time_tag_of< Duration, detail::time_duration_tag >, bool >::type wait_for(Duration const& duration)
     {
- timespec ts = boost::detail::to_timespec(duration);
- return do_wait_for(ts);
+ return priv_timed_wait(sync::detail::time_traits< Duration >::to_sync_unit(duration));
     }
 
- template <class Clock, class Duration>
- bool try_wait_until(const chrono::time_point<Clock, Duration> & timeout) BOOST_NOEXCEPT
+ template< typename TimePoint >
+ typename enable_if< detail::is_time_tag_of< TimePoint, detail::time_point_tag >, bool >::type wait_until(TimePoint const& abs_time)
     {
- return try_wait_for( timeout - Clock::now() );
+ return priv_timed_wait(sync::detail::time_traits< TimePoint >::to_sync_unit(abs_time));
     }
 
 private:
- bool do_wait_for(const struct timespec & timeout)
+ bool priv_timed_wait(sync::detail::system_time_point const& timeout)
     {
         // Try the fast path first
         if (this->try_wait())
@@ -156,7 +169,7 @@
             if (posts == 0)
             {
             again:
- const int status = sync::detail::linux_::futex_timedwait(reinterpret_cast< int* >(&m_state), old_state, &timeout);
+ const int status = sync::detail::linux_::futex_timedwait(reinterpret_cast< int* >(&m_state), old_state, &timeout.get());
                 if (status != 0)
                 {
                     const int err = errno;
@@ -209,107 +222,40 @@
         return true;
     }
 
-private:
- BOOST_STATIC_ASSERT_MSG(sizeof(detail::atomic_ns::atomic< unsigned int >) == sizeof(int), "Boost.Sync: unexpected size of atomic< unsigned int >");
- detail::atomic_ns::atomic< unsigned int > m_state;
-};
-
-class manual_reset_event
-{
- BOOST_DELETED_FUNCTION(manual_reset_event(manual_reset_event const&));
- BOOST_DELETED_FUNCTION(manual_reset_event& operator= (manual_reset_event const&));
-
-public:
- manual_reset_event() BOOST_NOEXCEPT :
- m_state(0)
+ bool priv_timed_wait(sync::detail::system_duration dur)
     {
+ return priv_timed_wait(sync::detail::system_time_point::now() + dur);
     }
 
- void post() BOOST_NOEXCEPT
+ template< typename TimePoint >
+ bool priv_timed_wait(sync::detail::chrono_time_point< TimePoint > const& t)
     {
- int old_state = m_state.exchange(1, detail::atomic_ns::memory_order_release); // set state
- if (old_state == 0)
- sync::detail::linux_::futex_broadcast(reinterpret_cast< int* >(&m_state)); // wake all threads
- }
-
- void wait() BOOST_NOEXCEPT
- {
- while (m_state.load(detail::atomic_ns::memory_order_acquire) == 0)
+ typedef TimePoint time_point;
+ typedef typename time_point::clock clock;
+ typedef typename time_point::duration duration;
+ time_point now = clock::now();
+ do
         {
- const int status = sync::detail::linux_::futex_wait(reinterpret_cast< int* >(&m_state), 0);
- if (status == 0)
- break;
-
- switch (errno)
- {
- case EINTR: // signal received
- case EWOULDBLOCK: // another thread has reset the event
- continue;
-
- default:
- BOOST_ASSERT(false);
- }
+ if (timed_wait(sync::detail::time_traits< duration >::to_sync_unit(t.get() - now)))
+ return true;
+ now = clock::now();
         }
- }
+ while (now < t.get());
 
- bool try_wait()
- {
- return m_state.load(detail::atomic_ns::memory_order_acquire) == 1;
- }
-
- void reset() BOOST_NOEXCEPT
- {
- m_state.store(0, detail::atomic_ns::memory_order_release);
- }
-
- template <typename Duration>
- bool try_wait_for(const Duration & duration) BOOST_NOEXCEPT
- {
- timespec ts = boost::detail::to_timespec( duration );
- return do_wait_for(ts);
- }
-
- template <class Clock, class Duration>
- bool try_wait_until(const chrono::time_point<Clock, Duration> & timeout ) BOOST_NOEXCEPT
- {
- return try_wait_for( timeout - Clock::now() );
+ return false;
     }
 
 private:
- bool do_wait_for(const struct timespec & timeout)
- {
- while (m_state.load(detail::atomic_ns::memory_order_acquire) == 0)
- {
- const int status = sync::detail::linux_::futex_timedwait(reinterpret_cast< int* >(&m_state), 0, &timeout);
- if (status == 0)
- break;
-
- switch (errno)
- {
- case ETIMEDOUT:
- return false;
-
- case EINTR: // signal received
- case EWOULDBLOCK: // another thread has reset the event
- continue;
-
- default:
- BOOST_ASSERT(false);
- }
- }
+ BOOST_STATIC_ASSERT_MSG(sizeof(detail::atomic_ns::atomic< unsigned int >) == sizeof(int), "Boost.Sync: unexpected size of atomic< unsigned int >");
+ detail::atomic_ns::atomic< unsigned int > m_state;
+};
 
- return true;
- }
+} // namespace abi
 
-private:
- BOOST_STATIC_ASSERT_MSG(sizeof(detail::atomic_ns::atomic< int >) == sizeof(int), "Boost.Sync: unexpected size of atomic< int >");
- detail::atomic_ns::atomic< int > m_state;
-};
+} // namespace sync
 
-}
-}
-}
+} // namespace boost
 
 #include <boost/sync/detail/footer.hpp>
 
-#endif // BOOST_SYNC_DETAIL_EVENT_EVENT_FUTEX_HPP_INCLUDED_
+#endif // BOOST_SYNC_DETAIL_EVENTS_AUTO_RESET_EVENT_FUTEX_HPP_INCLUDED_

Copied and modified: trunk/boost/sync/detail/events/auto_reset_event_semaphore.hpp (from r86335, trunk/boost/sync/detail/event/event_autoreset_semaphore.hpp)
==============================================================================
--- trunk/boost/sync/detail/event/event_autoreset_semaphore.hpp Wed Oct 16 13:49:10 2013 (r86335, copy source)
+++ trunk/boost/sync/detail/events/auto_reset_event_semaphore.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -7,19 +7,23 @@
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#ifndef BOOST_SYNC_DETAIL_EVENT_EVENT_AUTORESET_SEMAPHORE_HPP
-#define BOOST_SYNC_DETAIL_EVENT_EVENT_AUTORESET_SEMAPHORE_HPP
+#ifndef BOOST_SYNC_DETAIL_EVENTS_AUTO_RESET_EVENT_SEMAPHORE_HPP_INCLUDED_
+#define BOOST_SYNC_DETAIL_EVENTS_AUTO_RESET_EVENT_SEMAPHORE_HPP_INCLUDED_
 
 #include <cstddef>
 #include <boost/cstdint.hpp>
-
+#include <boost/utility/enable_if.hpp>
 #include <boost/sync/detail/config.hpp>
 #include <boost/sync/detail/atomic.hpp>
 #include <boost/sync/detail/pause.hpp>
+#include <boost/sync/detail/time_traits.hpp>
 #include <boost/sync/semaphore.hpp>
-
 #include <boost/sync/detail/header.hpp>
 
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
 namespace boost {
 
 namespace sync {
@@ -32,8 +36,7 @@
     BOOST_DELETED_FUNCTION(auto_reset_event& operator= (auto_reset_event const&));
 
 public:
- auto_reset_event() :
- m_state(0)
+ auto_reset_event() : m_state(0)
     {
     }
 
@@ -78,12 +81,12 @@
         return false;
     }
 
- template <typename Duration>
- bool try_wait_for(const Duration & duration)
+ template< typename Time >
+ typename enable_if_c< sync::detail::time_traits< Time >::is_specialized, bool >::type timed_wait(Time const& timeout)
     {
         m_state.fetch_add(1, detail::atomic_ns::memory_order_acquire);
 
- const bool wait_successful = m_sem.try_wait_for(duration);
+ const bool wait_successful = m_sem.timed_wait(timeout);
         if (wait_successful)
             return true;
 
@@ -91,22 +94,21 @@
         return false;
     }
 
- template <typename Timepoint>
- bool try_wait_until(const Timepoint & timeout )
+ template< typename Duration >
+ typename enable_if< detail::is_time_tag_of< Duration, detail::time_duration_tag >, bool >::type wait_for(Duration const& duration)
     {
- m_state.fetch_add(1, detail::atomic_ns::memory_order_acquire);
-
- const bool wait_successful = m_sem.try_wait_until(timeout);
- if (wait_successful)
- return true;
+ return timed_wait(duration);
+ }
 
- m_state.fetch_add(-1, detail::atomic_ns::memory_order_relaxed);
- return false;
+ template< typename TimePoint >
+ typename enable_if< detail::is_time_tag_of< TimePoint, detail::time_point_tag >, bool >::type wait_until(TimePoint const& abs_time)
+ {
+ return timed_wait(abs_time);
     }
 
 private:
     semaphore m_sem;
- detail::atomic_ns::atomic<int32_t> m_state;
+ detail::atomic_ns::atomic< int32_t > m_state;
 };
 
 } // namespace abi
@@ -117,4 +119,4 @@
 
 #include <boost/sync/detail/footer.hpp>
 
-#endif // BOOST_SYNC_DETAIL_EVENT_EVENT_AUTORESET_SEMAPHORE_HPP
+#endif // BOOST_SYNC_DETAIL_EVENTS_AUTO_RESET_EVENT_SEMAPHORE_HPP_INCLUDED_

Added: trunk/boost/sync/detail/events/auto_reset_event_windows.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/boost/sync/detail/events/auto_reset_event_windows.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -0,0 +1,73 @@
+// auto_reset_event_windows.hpp, win32 events
+//
+// Copyright (C) 2013 Tim Blechmann
+// Copyright (C) 2013 Andrey Semashev
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_SYNC_DETAIL_EVENTS_AUTO_RESET_EVENT_WINDOWS_HPP_INCLUDED_
+#define BOOST_SYNC_DETAIL_EVENTS_AUTO_RESET_EVENT_WINDOWS_HPP_INCLUDED_
+
+#include <boost/utility/enable_if.hpp>
+#include <boost/sync/detail/config.hpp>
+#include <boost/sync/detail/time_traits.hpp>
+#include <boost/sync/detail/events/basic_event_windows.hpp>
+#include <boost/sync/detail/header.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
+namespace boost {
+
+namespace sync {
+
+BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {
+
+class auto_reset_event
+{
+ BOOST_DELETED_FUNCTION(auto_reset_event(auto_reset_event const&))
+ BOOST_DELETED_FUNCTION(auto_reset_event& operator=(auto_reset_event const&))
+
+public:
+ auto_reset_event() : m_event(false)
+ {
+ }
+
+ void post() { m_event.set(); }
+ void wait() { m_event.wait(); }
+ bool try_wait() { return m_event.try_wait(); }
+
+ template< typename Time >
+ typename enable_if_c< sync::detail::time_traits< Time >::is_specialized, bool >::type timed_wait(Time const& timeout)
+ {
+ return m_event.timed_wait(sync::detail::time_traits< Time >::to_sync_unit(timeout));
+ }
+
+ template< typename Duration >
+ typename enable_if< detail::is_time_tag_of< Duration, detail::time_duration_tag >, bool >::type wait_for(Duration const& duration)
+ {
+ return m_event.timed_wait(sync::detail::time_traits< Duration >::to_sync_unit(duration));
+ }
+
+ template< typename TimePoint >
+ typename enable_if< detail::is_time_tag_of< TimePoint, detail::time_point_tag >, bool >::type wait_until(TimePoint const& abs_time)
+ {
+ return m_event.timed_wait(sync::detail::time_traits< TimePoint >::to_sync_unit(abs_time));
+ }
+
+private:
+ sync::detail::windows::basic_event m_event;
+};
+
+} // namespace abi
+
+} // namespace sync
+
+} // namespace boost
+
+#include <boost/sync/detail/footer.hpp>
+
+#endif // BOOST_SYNC_DETAIL_EVENTS_AUTO_RESET_EVENT_WINDOWS_HPP_INCLUDED_

Copied and modified: trunk/boost/sync/detail/events/basic_event_windows.hpp (from r86335, trunk/boost/sync/detail/event/event_windows.hpp)
==============================================================================
--- trunk/boost/sync/detail/event/event_windows.hpp Wed Oct 16 13:49:10 2013 (r86335, copy source)
+++ trunk/boost/sync/detail/events/basic_event_windows.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -1,181 +1,201 @@
-// event.hpp, win32 events
+// basic_event_windows.hpp, base class for win32 events
 //
 // Copyright (C) 2013 Tim Blechmann
+// Copyright (C) 2013 Andrey Semashev
 //
 // Distributed under the Boost Software License, Version 1.0. (See
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#ifndef BOOST_SYNC_DETAIL_EVENT_EVENT_WINDOWS_HPP_INCLUDED_
-#define BOOST_SYNC_DETAIL_EVENT_EVENT_WINDOWS_HPP_INCLUDED_
+#ifndef BOOST_SYNC_DETAIL_EVENTS_BASIC_EVENT_WINDOWS_HPP_INCLUDED_
+#define BOOST_SYNC_DETAIL_EVENTS_BASIC_EVENT_WINDOWS_HPP_INCLUDED_
 
 #include <cstddef>
 #include <boost/assert.hpp>
 #include <boost/detail/winapi/GetLastError.hpp>
 #include <boost/detail/winapi/synchronization.hpp>
 #include <boost/detail/winapi/handles.hpp>
-
 #include <boost/sync/detail/config.hpp>
+#include <boost/sync/detail/time_units.hpp>
+#include <boost/sync/detail/time_traits.hpp>
+#include <boost/sync/detail/waitable_timer.hpp>
 #include <boost/sync/detail/throw_exception.hpp>
+#include <boost/sync/exceptions/runtime_exception.hpp>
 #include <boost/sync/exceptions/resource_error.hpp>
+#include <boost/sync/exceptions/wait_error.hpp>
 #include <boost/sync/detail/header.hpp>
 
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
 namespace boost {
 
 namespace sync {
 
-BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {
+namespace detail {
 
-class win32_event_base
-{
- BOOST_DELETED_FUNCTION(win32_event_base(win32_event_base const&))
- BOOST_DELETED_FUNCTION(win32_event_base& operator=(win32_event_base const&))
+namespace windows {
 
- typedef boost::detail::winapi::HANDLE_ HANDLE_;
- typedef boost::detail::winapi::BOOL_ BOOL_;
- typedef boost::detail::winapi::DWORD_ DWORD_;
+class basic_event
+{
+ BOOST_DELETED_FUNCTION(basic_event(basic_event const&))
+ BOOST_DELETED_FUNCTION(basic_event& operator=(basic_event const&))
 
 public:
- explicit win32_event_base(bool auto_reset)
+ explicit basic_event(bool manual_reset)
     {
- handle_ = boost::detail::winapi::create_anonymous_event(NULL, !auto_reset, 0);
- if (!handle_)
+ m_handle = boost::detail::winapi::create_anonymous_event(NULL, manual_reset, 0);
+ if (!m_handle)
         {
- const DWORD_ err = boost::detail::winapi::GetLastError();
- BOOST_SYNC_DETAIL_THROW(resource_error, (err)("boost::sync::event constructor failed in CreateEvent"));
+ const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError();
+ BOOST_SYNC_DETAIL_THROW(resource_error, (err)("event constructor failed in CreateEvent"));
         }
     }
 
- ~win32_event_base() BOOST_NOEXCEPT
+ ~basic_event()
     {
- BOOST_VERIFY( boost::detail::winapi::CloseHandle(handle_) );
+ BOOST_VERIFY(boost::detail::winapi::CloseHandle(m_handle));
     }
 
- void post()
+ void set()
     {
- const BOOL_ status = boost::detail::winapi::SetEvent(handle_);
+ const boost::detail::winapi::BOOL_ status = boost::detail::winapi::SetEvent(m_handle);
         if (status == 0)
         {
- const DWORD_ err = boost::detail::winapi::GetLastError();
- BOOST_SYNC_DETAIL_THROW(resource_error, (err)("boost::sync::event::post failed in ReleaseEvent"));
+ const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError();
+ BOOST_SYNC_DETAIL_THROW(runtime_exception, (err)("event::set failed in SetEvent"));
         }
     }
 
     void reset()
     {
- const BOOL_ status = boost::detail::winapi::ResetEvent(handle_);
+ const boost::detail::winapi::BOOL_ status = boost::detail::winapi::ResetEvent(m_handle);
         if (status == 0)
         {
- const DWORD_ err = boost::detail::winapi::GetLastError();
- BOOST_SYNC_DETAIL_THROW(resource_error, (err)("boost::sync::event::reset failed in ResetEvent"));
+ const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError();
+ BOOST_SYNC_DETAIL_THROW(runtime_exception, (err)("event::reset failed in ResetEvent"));
         }
     }
 
- bool wait()
+ void wait()
     {
- using namespace boost::detail::winapi;
-
- switch ( WaitForSingleObject(handle_, infinite) )
+ const boost::detail::winapi::DWORD_ res = boost::detail::winapi::WaitForSingleObject(m_handle, boost::detail::winapi::infinite);
+ if (BOOST_UNLIKELY(res != boost::detail::winapi::wait_object_0))
         {
- case wait_object_0:
- return true;
-
- case wait_failed:
- {
- const DWORD_ err = boost::detail::winapi::GetLastError();
- BOOST_SYNC_DETAIL_THROW(resource_error, (err)("boost::sync::event::wait failed in WaitForSingleObject"));
- }
-
- default:
- BOOST_ASSERT(false);
- return false;
+ const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError();
+ BOOST_SYNC_DETAIL_THROW(wait_error, (err)("event::wait failed in WaitForSingleObject"));
         }
     }
 
     bool try_wait()
     {
- return do_try_wait_for( 0 );
- }
+ const boost::detail::winapi::DWORD_ res = boost::detail::winapi::WaitForSingleObject(m_handle, 0);
+ if (res == boost::detail::winapi::wait_object_0)
+ return true;
 
- template <class Rep, class Period>
- bool try_wait_for(const chrono::duration<Rep, Period> & rel_time)
- {
- return do_try_wait_for(static_cast< DWORD_ >(chrono::duration_cast<chrono::milliseconds>( rel_time ).count()));
+ if (BOOST_UNLIKELY(res != boost::detail::winapi::wait_timeout))
+ {
+ const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError();
+ BOOST_SYNC_DETAIL_THROW(wait_error, (err)("event::try_wait failed in WaitForSingleObject"));
+ }
+
+ return false;
     }
 
- template <class Clock, class Duration>
- bool try_wait_until(const chrono::time_point<Clock, Duration> & timeout )
+ bool timed_wait(sync::detail::system_duration t)
     {
- typename Clock::time_point c_now = Clock::now();
- return try_wait_for( timeout - c_now );
+ sync::detail::system_duration::native_type time_left = t.get();
+ if (time_left < 0)
+ time_left = 0;
+
+ do
+ {
+ const boost::detail::winapi::DWORD_ dur = time_left > boost::detail::winapi::max_non_infinite_wait ?
+ boost::detail::winapi::max_non_infinite_wait : static_cast< boost::detail::winapi::DWORD_ >(time_left);
+ const boost::detail::winapi::DWORD_ res = boost::detail::winapi::WaitForSingleObject(m_handle, dur);
+ switch (res)
+ {
+ case boost::detail::winapi::wait_object_0: // event was signalled
+ return true;
+
+ case boost::detail::winapi::wait_timeout: // timeout expired
+ time_left -= dur;
+ break;
+
+ default: // error occurred
+ {
+ const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError();
+ BOOST_SYNC_DETAIL_THROW(wait_error, (err)("event timed_wait failed in WaitForSingleObject"));
+ }
+ }
+ }
+ while (time_left > 0);
+
+ return false;
     }
 
-private:
- bool do_try_wait_for( DWORD_ milliseconds )
+ bool timed_wait(sync::detail::system_time_point const& t)
     {
- using namespace boost::detail::winapi;
+ boost::detail::winapi::HANDLE_ handles[2];
+ handles[0] = m_handle;
+ handles[1] = sync::detail::windows::get_waitable_timer();
 
- switch ( WaitForSingleObject(handle_, milliseconds) )
+ if (!boost::detail::winapi::SetWaitableTimer(handles[1], reinterpret_cast< const boost::detail::winapi::LARGE_INTEGER_* >(&t.get()), 0, NULL, NULL, false))
         {
- case wait_object_0:
- return true;
+ const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError();
+ BOOST_SYNC_DETAIL_THROW(wait_error, (err)("event timed_wait failed to set a timeout"));
+ }
 
- case wait_timeout:
- return false;
+ const boost::detail::winapi::DWORD_ res = boost::detail::winapi::WaitForMultipleObjects(sizeof(handles) / sizeof(*handles), handles, false, boost::detail::winapi::infinite);
+ if (BOOST_UNLIKELY(res == boost::detail::winapi::wait_failed))
+ {
+ const boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError();
+ BOOST_SYNC_DETAIL_THROW(wait_error, (err)("event timed_wait failed in WaitForMultipleObjects"));
+ }
 
- case wait_failed:
- {
- const DWORD_ err = boost::detail::winapi::GetLastError();
- BOOST_SYNC_DETAIL_THROW(resource_error, (err)("boost::sync::event::do_try_wait_for failed in WaitForSingleObject"));
- }
+ switch (res)
+ {
+ case boost::detail::winapi::wait_object_0: // event was signalled
+ return true;
 
         default:
             BOOST_ASSERT(false);
+ case boost::detail::winapi::wait_object_0 + 1: // timeout has expired
             return false;
         }
     }
 
- HANDLE_ handle_;
-};
-
-class auto_reset_event : win32_event_base
-{
-public:
- auto_reset_event() : win32_event_base(true) {}
-
- void post() { win32_event_base::post(); }
- void wait() { win32_event_base::wait(); }
- bool try_wait() { return win32_event_base::try_wait(); }
+ template< typename TimePoint >
+ bool timed_wait(sync::detail::chrono_time_point< TimePoint > const& t)
+ {
+ typedef TimePoint time_point;
+ typedef typename time_point::clock clock;
+ typedef typename time_point::duration duration;
+ time_point now = clock::now();
+ do
+ {
+ if (timed_wait(sync::detail::time_traits< duration >::to_sync_unit(t.get() - now)))
+ return true;
+ now = clock::now();
+ }
+ while (now < t.get());
 
- template <typename Duration>
- bool try_wait_for(const Duration & duration) { return win32_event_base::try_wait_for( duration ); }
+ return false;
+ }
 
- template <typename TimePoint>
- bool try_wait_until(const TimePoint & timeout) { return win32_event_base::try_wait_until( timeout ); }
+private:
+ boost::detail::winapi::HANDLE_ m_handle;
 };
 
-class manual_reset_event : win32_event_base
-{
-public:
- manual_reset_event() : win32_event_base(false) {}
-
- void post() { win32_event_base::post(); }
- void wait() { win32_event_base::wait(); }
- bool try_wait() { return win32_event_base::try_wait(); }
- void reset() { win32_event_base::reset(); }
-
- template <typename Duration>
- bool try_wait_for(const Duration & duration) { return win32_event_base::try_wait_for( duration ); }
+} // namespace windows
 
- template <typename TimePoint>
- bool try_wait_until(const TimePoint & timeout) { return win32_event_base::try_wait_until( timeout ); }
-};
+} // namespace detail
 
+} // namespace sync
 
-}
-}
-}
+} // namespace boost
 
 #include <boost/sync/detail/footer.hpp>
 
-#endif // BOOST_SYNC_DETAIL_EVENT_EVENT_WINDOWS_HPP_INCLUDED_
+#endif // BOOST_SYNC_DETAIL_EVENTS_BASIC_EVENT_WINDOWS_HPP_INCLUDED_

Deleted: trunk/boost/sync/detail/event/event_autoreset_semaphore.hpp
==============================================================================
--- trunk/boost/sync/detail/event/event_autoreset_semaphore.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86335)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,120 +0,0 @@
-// autoreset event for generic semaphores
-//
-// Copyright (C) 2013 Tim Blechmann
-// Copyright (C) 2013 Andrey Semashev
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_SYNC_DETAIL_EVENT_EVENT_AUTORESET_SEMAPHORE_HPP
-#define BOOST_SYNC_DETAIL_EVENT_EVENT_AUTORESET_SEMAPHORE_HPP
-
-#include <cstddef>
-#include <boost/cstdint.hpp>
-
-#include <boost/sync/detail/config.hpp>
-#include <boost/sync/detail/atomic.hpp>
-#include <boost/sync/detail/pause.hpp>
-#include <boost/sync/semaphore.hpp>
-
-#include <boost/sync/detail/header.hpp>
-
-namespace boost {
-
-namespace sync {
-
-BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {
-
-class auto_reset_event
-{
- BOOST_DELETED_FUNCTION(auto_reset_event(auto_reset_event const&))
- BOOST_DELETED_FUNCTION(auto_reset_event& operator= (auto_reset_event const&));
-
-public:
- auto_reset_event() :
- m_state(0)
- {
- }
-
- void post() BOOST_NOEXCEPT
- {
- int32_t old_state = m_state.load(detail::atomic_ns::memory_order_acquire);
- if (old_state >= 0)
- {
- for (;;)
- {
- if (m_state.compare_exchange_weak(old_state, old_state - 1, detail::atomic_ns::memory_order_release, detail::atomic_ns::memory_order_acquire))
- {
- m_sem.post();
- return; // avoid unnecessary fence
- }
-
- if (old_state < 0)
- break; // someone else has set the auto_reset_event with no waiters
-
- detail::pause();
- }
- }
-
- detail::atomic_ns::atomic_thread_fence(detail::atomic_ns::memory_order_release);
- }
-
- void wait()
- {
- m_state.fetch_add(1, detail::atomic_ns::memory_order_acquire);
- m_sem.wait();
- }
-
- bool try_wait()
- {
- m_state.fetch_add(1, detail::atomic_ns::memory_order_acquire);
-
- const bool wait_successful = m_sem.try_wait();
- if (wait_successful)
- return true;
-
- m_state.fetch_add(-1, detail::atomic_ns::memory_order_relaxed);
- return false;
- }
-
- template <typename Duration>
- bool try_wait_for(const Duration & duration)
- {
- m_state.fetch_add(1, detail::atomic_ns::memory_order_acquire);
-
- const bool wait_successful = m_sem.try_wait_for(duration);
- if (wait_successful)
- return true;
-
- m_state.fetch_add(-1, detail::atomic_ns::memory_order_relaxed);
- return false;
- }
-
- template <typename Timepoint>
- bool try_wait_until(const Timepoint & timeout )
- {
- m_state.fetch_add(1, detail::atomic_ns::memory_order_acquire);
-
- const bool wait_successful = m_sem.try_wait_until(timeout);
- if (wait_successful)
- return true;
-
- m_state.fetch_add(-1, detail::atomic_ns::memory_order_relaxed);
- return false;
- }
-
-private:
- semaphore m_sem;
- detail::atomic_ns::atomic<int32_t> m_state;
-};
-
-} // namespace abi
-
-} // namespace sync
-
-} // namespace boost
-
-#include <boost/sync/detail/footer.hpp>
-
-#endif // BOOST_SYNC_DETAIL_EVENT_EVENT_AUTORESET_SEMAPHORE_HPP

Deleted: trunk/boost/sync/detail/event/event_emulation.hpp
==============================================================================
--- trunk/boost/sync/detail/event/event_emulation.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86335)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,209 +0,0 @@
-// event.hpp, condition variable emulation
-//
-// Copyright (C) 2013 Tim Blechmann
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_SYNC_DETAIL_EVENT_EVENT_EMULATION_HPP_INCLUDED_
-#define BOOST_SYNC_DETAIL_EVENT_EVENT_EMULATION_HPP_INCLUDED_
-
-#include <boost/sync/semaphore.hpp>
-
-// we use the semaphore implementation if we have native semaphores
-#ifndef BOOST_SYNC_SEMAPHORE_EMULATED
-#include <boost/sync/detail/event/event_autoreset_semaphore.hpp>
-#endif
-
-
-#include <boost/thread/condition_variable.hpp>
-#include <boost/thread/shared_mutex.hpp>
-#include <boost/thread/locks.hpp>
-
-#include <boost/sync/detail/config.hpp>
-//#include <boost/sync/locks/lock_guard.hpp>
-//#include <boost/sync/locks/unique_lock.hpp>
-#include <boost/sync/detail/header.hpp>
-
-#define BOOST_SYNC_EVENT_EMULATED
-
-namespace boost {
-namespace sync {
-BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {
-
-
-#ifdef BOOST_SYNC_SEMAPHORE_EMULATED
-
-class auto_reset_event
-{
- BOOST_DELETED_FUNCTION(auto_reset_event(auto_reset_event const&));
- BOOST_DELETED_FUNCTION(auto_reset_event& operator=(auto_reset_event const&));
-
-public:
- auto_reset_event() BOOST_NOEXCEPT :
- m_is_set(false)
- {}
-
- void post()
- {
- unique_lock<upgrade_mutex> lock(m_mutex);
- bool already_signaled = m_is_set;
- m_is_set = true;
- if (!already_signaled)
- m_cond.notify_one();
- }
-
- void wait()
- {
- upgrade_lock<upgrade_mutex> lock(m_mutex);
-
- while (!m_is_set)
- m_cond.wait(lock);
-
- upgrade_to_unique_lock<upgrade_mutex> unique_lock(lock);
- m_is_set = false;
- }
-
- void reset()
- {
- lock_guard<upgrade_mutex> lock(m_mutex);
- m_is_set = false;
- }
-
- bool try_wait()
- {
- lock_guard<upgrade_mutex> lock(m_mutex);
- const bool res = m_is_set;
- if (res)
- m_is_set = false;
- return res;
- }
-
- template <class Duration>
- bool try_wait_for(const Duration & duration)
- {
- upgrade_lock<upgrade_mutex> lock(m_mutex);
-
- while (!m_is_set) {
- if (m_cond.wait_for(lock, duration) == cv_status::timeout) {
- if (!m_is_set)
- return false;
- break;
- }
- }
-
- upgrade_to_unique_lock<upgrade_mutex> unique_lock(lock);
- m_is_set = false;
- return true;
- }
-
- template <typename TimePoint>
- bool try_wait_until(const TimePoint & timeout)
- {
- upgrade_lock<upgrade_mutex> lock(m_mutex);
-
- while (!m_is_set) {
- if (m_cond.wait_until(lock, timeout) == cv_status::timeout) {
- if (!m_is_set)
- return false;
- break;
- }
- }
-
- upgrade_to_unique_lock<upgrade_mutex> unique_lock(lock);
- m_is_set = false;
- return true;
- }
-
-private:
- bool m_is_set;
- upgrade_mutex m_mutex;
- condition_variable_any m_cond;
-};
-
-#endif
-
-class manual_reset_event
-{
- BOOST_DELETED_FUNCTION(manual_reset_event(manual_reset_event const&));
- BOOST_DELETED_FUNCTION(manual_reset_event& operator=(manual_reset_event const&));
-
-public:
- manual_reset_event() BOOST_NOEXCEPT :
- m_is_set(false)
- {}
-
- void post()
- {
- unique_lock<upgrade_mutex> lock(m_mutex);
- bool already_signaled = m_is_set;
- m_is_set = true;
- m_cond.notify_all();
- }
-
- void wait()
- {
- upgrade_lock<upgrade_mutex> lock(m_mutex);
-
- while (!m_is_set)
- m_cond.wait(lock);
- }
-
- void reset()
- {
- lock_guard<upgrade_mutex> lock(m_mutex);
- m_is_set = false;
- }
-
- bool try_wait()
- {
- lock_guard<upgrade_mutex> lock(m_mutex);
- return m_is_set;
- }
-
- template <typename Duration>
- bool try_wait_for(const Duration & duration)
- {
- upgrade_lock<upgrade_mutex> lock(m_mutex);
-
- while (!m_is_set) {
- if (m_cond.wait_for(lock, duration) == cv_status::timeout) {
- if (!m_is_set)
- return false;
- break;
- }
- }
-
- return true;
- }
-
- template <typename TimePoint>
- bool try_wait_until(const TimePoint & timeout)
- {
- upgrade_lock<upgrade_mutex> lock(m_mutex);
-
- while (!m_is_set) {
- if (m_cond.wait_until(lock, timeout) == cv_status::timeout) {
- if (!m_is_set)
- return false;
- break;
- }
- }
-
- return true;
- }
-
-private:
- bool m_is_set;
- upgrade_mutex m_mutex;
- condition_variable_any m_cond;
-};
-
-}
-}
-}
-
-#include <boost/sync/detail/footer.hpp>
-
-#endif // BOOST_SYNC_DETAIL_EVENT_EVENT_EMULATION_HPP_INCLUDED_

Deleted: trunk/boost/sync/detail/event/event_futex.hpp
==============================================================================
--- trunk/boost/sync/detail/event/event_futex.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86335)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,315 +0,0 @@
-// event.hpp, futex-based event
-//
-// Copyright (C) 2013 Tim Blechmann
-// Copyright (C) 2013 Andrey Semashev
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_SYNC_DETAIL_EVENT_EVENT_FUTEX_HPP_INCLUDED_
-#define BOOST_SYNC_DETAIL_EVENT_EVENT_FUTEX_HPP_INCLUDED_
-
-#include <errno.h>
-#include <sys/time.h>
-
-#include <boost/assert.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/sync/detail/config.hpp>
-#include <boost/sync/detail/atomic.hpp>
-#include <boost/sync/detail/pause.hpp>
-#include <boost/sync/detail/futex.hpp>
-
-#include <boost/sync/detail/header.hpp>
-
-namespace boost {
-namespace sync {
-BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {
-
-class auto_reset_event
-{
- BOOST_DELETED_FUNCTION(auto_reset_event(auto_reset_event const&));
- BOOST_DELETED_FUNCTION(auto_reset_event& operator= (auto_reset_event const&));
-
-private:
- // State bits are divided into post count and waiter count. Post counter is needed to wake
- // the correct number of threads blocked on the event in case if multiple concurrent posts are made.
- enum
- {
- post_count_lowest_bit = 22u,
- post_count_one = 1u << post_count_lowest_bit,
- post_count_mask = 0u - post_count_one,
- wait_count_mask = (~0u) ^ post_count_mask
- };
-
-public:
- auto_reset_event() BOOST_NOEXCEPT : m_state(0)
- {
- }
-
- void post() BOOST_NOEXCEPT
- {
- unsigned int old_state = m_state.load(detail::atomic_ns::memory_order_acquire);
- unsigned int waiters, posts;
- while (true)
- {
- waiters = old_state & wait_count_mask;
- posts = old_state >> post_count_lowest_bit;
- if (waiters >= posts)
- {
- if (m_state.compare_exchange_weak(old_state, old_state + post_count_one, detail::atomic_ns::memory_order_acquire, detail::atomic_ns::memory_order_release))
- break;
-
- detail::pause();
- }
- else
- return; // the event is already set (enough times so that all waiters are released and the event is still left signalled)
- }
-
- if (waiters > 0)
- sync::detail::linux_::futex_signal(reinterpret_cast< int* >(&m_state));
- }
-
- void wait() BOOST_NOEXCEPT
- {
- // Try the fast path first
- if (this->try_wait())
- return;
-
- // Add one waiter
- unsigned int old_state = m_state.fetch_add(1, detail::atomic_ns::memory_order_acq_rel);
- while (true)
- {
- unsigned int posts = old_state >> post_count_lowest_bit;
- if (posts == 0)
- {
- again:
- const int status = sync::detail::linux_::futex_wait(reinterpret_cast< int* >(&m_state), old_state);
- if (status != 0)
- {
- const int err = errno;
- switch (err)
- {
- case EINTR: // signal received
- goto again;
-
- case EWOULDBLOCK: // another thread changed the state
- break;
-
- default:
- BOOST_ASSERT(false);
- }
- }
-
- old_state = m_state.load(detail::atomic_ns::memory_order_acquire);
- posts = old_state >> post_count_lowest_bit;
- if (posts == 0)
- goto again;
- }
-
- // Remove one post and one waiter from the counters
- if (m_state.compare_exchange_strong(old_state, old_state - (post_count_one + 1u), detail::atomic_ns::memory_order_acquire, detail::atomic_ns::memory_order_release))
- break;
- }
- }
-
- bool try_wait() BOOST_NOEXCEPT
- {
- unsigned int old_state = m_state.load(detail::atomic_ns::memory_order_acquire);
-
- for (unsigned int posts = old_state >> post_count_lowest_bit; posts > 0; posts = old_state >> post_count_lowest_bit)
- {
- if (m_state.compare_exchange_weak(old_state, old_state - post_count_one, detail::atomic_ns::memory_order_acquire, detail::atomic_ns::memory_order_release))
- return true;
-
- detail::pause();
- }
-
- return false;
- }
-
- template <typename Duration>
- bool try_wait_for(const Duration & duration) BOOST_NOEXCEPT
- {
- timespec ts = boost::detail::to_timespec(duration);
- return do_wait_for(ts);
- }
-
- template <class Clock, class Duration>
- bool try_wait_until(const chrono::time_point<Clock, Duration> & timeout) BOOST_NOEXCEPT
- {
- return try_wait_for( timeout - Clock::now() );
- }
-
-private:
- bool do_wait_for(const struct timespec & timeout)
- {
- // Try the fast path first
- if (this->try_wait())
- return true;
-
- // Add one waiter
- unsigned int old_state = m_state.fetch_add(1, detail::atomic_ns::memory_order_acq_rel);
- while (true)
- {
- unsigned int posts = old_state >> post_count_lowest_bit;
- if (posts == 0)
- {
- again:
- const int status = sync::detail::linux_::futex_timedwait(reinterpret_cast< int* >(&m_state), old_state, &timeout);
- if (status != 0)
- {
- const int err = errno;
- switch (err)
- {
- case ETIMEDOUT:
- old_state = m_state.load(detail::atomic_ns::memory_order_acquire);
- while (true)
- {
- posts = old_state >> post_count_lowest_bit;
- if (posts == 0)
- {
- // Remove one waiter
- if (m_state.compare_exchange_weak(old_state, old_state - 1u, detail::atomic_ns::memory_order_acquire, detail::atomic_ns::memory_order_release))
- return false;
- }
- else
- {
- // Remove one post and one waiter from the counters
- if (m_state.compare_exchange_weak(old_state, old_state - (post_count_one + 1u), detail::atomic_ns::memory_order_acquire, detail::atomic_ns::memory_order_release))
- return true;
- }
-
- detail::pause();
- }
- break;
-
- case EINTR: // signal received
- goto again;
-
- case EWOULDBLOCK: // another thread changed the state
- break;
-
- default:
- BOOST_ASSERT(false);
- }
- }
-
- old_state = m_state.load(detail::atomic_ns::memory_order_acquire);
- posts = old_state >> post_count_lowest_bit;
- if (posts == 0)
- goto again;
- }
-
- // Remove one post and one waiter from the counters
- if (m_state.compare_exchange_strong(old_state, old_state - (post_count_one + 1u), detail::atomic_ns::memory_order_acquire, detail::atomic_ns::memory_order_release))
- break;
- }
-
- return true;
- }
-
-private:
- BOOST_STATIC_ASSERT_MSG(sizeof(detail::atomic_ns::atomic< unsigned int >) == sizeof(int), "Boost.Sync: unexpected size of atomic< unsigned int >");
- detail::atomic_ns::atomic< unsigned int > m_state;
-};
-
-class manual_reset_event
-{
- BOOST_DELETED_FUNCTION(manual_reset_event(manual_reset_event const&));
- BOOST_DELETED_FUNCTION(manual_reset_event& operator= (manual_reset_event const&));
-
-public:
- manual_reset_event() BOOST_NOEXCEPT :
- m_state(0)
- {
- }
-
- void post() BOOST_NOEXCEPT
- {
- int old_state = m_state.exchange(1, detail::atomic_ns::memory_order_release); // set state
- if (old_state == 0)
- sync::detail::linux_::futex_broadcast(reinterpret_cast< int* >(&m_state)); // wake all threads
- }
-
- void wait() BOOST_NOEXCEPT
- {
- while (m_state.load(detail::atomic_ns::memory_order_acquire) == 0)
- {
- const int status = sync::detail::linux_::futex_wait(reinterpret_cast< int* >(&m_state), 0);
- if (status == 0)
- break;
-
- switch (errno)
- {
- case EINTR: // signal received
- case EWOULDBLOCK: // another thread has reset the event
- continue;
-
- default:
- BOOST_ASSERT(false);
- }
- }
- }
-
- bool try_wait()
- {
- return m_state.load(detail::atomic_ns::memory_order_acquire) == 1;
- }
-
- void reset() BOOST_NOEXCEPT
- {
- m_state.store(0, detail::atomic_ns::memory_order_release);
- }
-
- template <typename Duration>
- bool try_wait_for(const Duration & duration) BOOST_NOEXCEPT
- {
- timespec ts = boost::detail::to_timespec( duration );
- return do_wait_for(ts);
- }
-
- template <class Clock, class Duration>
- bool try_wait_until(const chrono::time_point<Clock, Duration> & timeout ) BOOST_NOEXCEPT
- {
- return try_wait_for( timeout - Clock::now() );
- }
-
-private:
- bool do_wait_for(const struct timespec & timeout)
- {
- while (m_state.load(detail::atomic_ns::memory_order_acquire) == 0)
- {
- const int status = sync::detail::linux_::futex_timedwait(reinterpret_cast< int* >(&m_state), 0, &timeout);
- if (status == 0)
- break;
-
- switch (errno)
- {
- case ETIMEDOUT:
- return false;
-
- case EINTR: // signal received
- case EWOULDBLOCK: // another thread has reset the event
- continue;
-
- default:
- BOOST_ASSERT(false);
- }
- }
-
- return true;
- }
-
-private:
- BOOST_STATIC_ASSERT_MSG(sizeof(detail::atomic_ns::atomic< int >) == sizeof(int), "Boost.Sync: unexpected size of atomic< int >");
- detail::atomic_ns::atomic< int > m_state;
-};
-
-}
-}
-}
-
-#include <boost/sync/detail/footer.hpp>
-
-#endif // BOOST_SYNC_DETAIL_EVENT_EVENT_FUTEX_HPP_INCLUDED_

Deleted: trunk/boost/sync/detail/event/event_mach.hpp
==============================================================================
--- trunk/boost/sync/detail/event/event_mach.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86335)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,124 +0,0 @@
-// event.hpp, mach events
-//
-// Copyright (C) 2013 Tim Blechmann
-// Copyright (C) 2013 Andrey Semashev
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_SYNC_EVENT_DETAIL_DARWIN_EVENT_MACH_HPP
-#define BOOST_SYNC_EVENT_DETAIL_DARWIN_EVENT_MACH_HPP
-
-// auto_reset_event is implemented via sync::semaphores:
-#include <boost/sync/detail/event/event_autoreset_semaphore.hpp>
-
-
-#include <cstddef>
-#include <boost/assert.hpp>
-#include <boost/cstdint.hpp>
-
-#include <boost/sync/detail/config.hpp>
-#include <boost/sync/detail/atomic.hpp>
-#include <boost/sync/detail/pause.hpp>
-#include <boost/sync/exceptions/resource_error.hpp>
-
-#include <mach/task.h>
-#include <mach/semaphore.h>
-#include <mach/mach_traps.h>
-#include <mach/mach_init.h>
-
-#include <boost/sync/detail/header.hpp>
-
-namespace boost {
-
-namespace sync {
-
-BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {
-
-
-class manual_reset_event
-{
- BOOST_DELETED_FUNCTION(manual_reset_event(manual_reset_event const&))
- BOOST_DELETED_FUNCTION(manual_reset_event& operator=(manual_reset_event const&));
-
-public:
- manual_reset_event() BOOST_NOEXCEPT :
- m_state(0)
- {
- kern_return_t result = semaphore_create(mach_task_self(), &m_sem, SYNC_POLICY_FIFO, 0);
- BOOST_VERIFY(result == KERN_SUCCESS);
- }
-
- ~manual_reset_event() BOOST_NOEXCEPT
- {
- kern_return_t result = semaphore_destroy(mach_task_self(), m_sem);
- BOOST_VERIFY(result == KERN_SUCCESS);
- }
-
- void post() BOOST_NOEXCEPT
- {
- m_state.store( 1, detail::atomic_ns::memory_order_release );
- semaphore_signal_all( m_sem ); // wake all threads!& reset semaphore count
- }
-
- void reset() BOOST_NOEXCEPT
- {
- m_state = 0;
- }
-
- void wait() BOOST_NOEXCEPT
- {
- if (m_state.load(detail::atomic_ns::memory_order_acquire) == 1)
- return;
-
- kern_return_t result = semaphore_wait( m_sem );
- BOOST_VERIFY (result == KERN_SUCCESS);
- }
-
- bool try_wait() BOOST_NOEXCEPT
- {
- const mach_timespec_t immediate = {0, 0};
- return do_try_wait_until(immediate);
- }
-
- template <class Rep, class Period>
- bool try_wait_for(const chrono::duration<Rep, Period> & duration) BOOST_NOEXCEPT
- {
- chrono::seconds seconds = chrono::duration_cast<chrono::seconds>(duration);
- chrono::nanoseconds nanoseconds = chrono::duration_cast<chrono::nanoseconds>(duration) - seconds;
-
- const mach_timespec_t mach_duration = { static_cast<unsigned int>(seconds.count()), static_cast<clock_res_t>(nanoseconds.count()) };
- return do_try_wait_until( mach_duration );
- }
-
- template <class Clock, class Duration>
- bool try_wait_until(const chrono::time_point<Clock, Duration> & timeout ) BOOST_NOEXCEPT
- {
- return try_wait_for( timeout - Clock::now() );
- }
-
-private:
- bool do_try_wait_until (const mach_timespec_t & timeout)
- {
- if (m_state.load( detail::atomic_ns::memory_order_acquire ) == 1)
- return true;
-
- kern_return_t result = semaphore_timedwait( m_sem, timeout );
- if (result == KERN_SUCCESS)
- return true;
- else
- return false;
- }
-
- semaphore_t m_sem;
- detail::atomic_ns::atomic<int32_t> m_state;
-};
-
-}
-}
-}
-
-#include <boost/sync/detail/footer.hpp>
-
-#endif // BOOST_SYNC_EVENT_DETAIL_DARWIN_EVENT_MACH_HPP

Deleted: trunk/boost/sync/detail/event/event_windows.hpp
==============================================================================
--- trunk/boost/sync/detail/event/event_windows.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86335)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,181 +0,0 @@
-// event.hpp, win32 events
-//
-// Copyright (C) 2013 Tim Blechmann
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_SYNC_DETAIL_EVENT_EVENT_WINDOWS_HPP_INCLUDED_
-#define BOOST_SYNC_DETAIL_EVENT_EVENT_WINDOWS_HPP_INCLUDED_
-
-#include <cstddef>
-#include <boost/assert.hpp>
-#include <boost/detail/winapi/GetLastError.hpp>
-#include <boost/detail/winapi/synchronization.hpp>
-#include <boost/detail/winapi/handles.hpp>
-
-#include <boost/sync/detail/config.hpp>
-#include <boost/sync/detail/throw_exception.hpp>
-#include <boost/sync/exceptions/resource_error.hpp>
-#include <boost/sync/detail/header.hpp>
-
-namespace boost {
-
-namespace sync {
-
-BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {
-
-class win32_event_base
-{
- BOOST_DELETED_FUNCTION(win32_event_base(win32_event_base const&))
- BOOST_DELETED_FUNCTION(win32_event_base& operator=(win32_event_base const&))
-
- typedef boost::detail::winapi::HANDLE_ HANDLE_;
- typedef boost::detail::winapi::BOOL_ BOOL_;
- typedef boost::detail::winapi::DWORD_ DWORD_;
-
-public:
- explicit win32_event_base(bool auto_reset)
- {
- handle_ = boost::detail::winapi::create_anonymous_event(NULL, !auto_reset, 0);
- if (!handle_)
- {
- const DWORD_ err = boost::detail::winapi::GetLastError();
- BOOST_SYNC_DETAIL_THROW(resource_error, (err)("boost::sync::event constructor failed in CreateEvent"));
- }
- }
-
- ~win32_event_base() BOOST_NOEXCEPT
- {
- BOOST_VERIFY( boost::detail::winapi::CloseHandle(handle_) );
- }
-
- void post()
- {
- const BOOL_ status = boost::detail::winapi::SetEvent(handle_);
- if (status == 0)
- {
- const DWORD_ err = boost::detail::winapi::GetLastError();
- BOOST_SYNC_DETAIL_THROW(resource_error, (err)("boost::sync::event::post failed in ReleaseEvent"));
- }
- }
-
- void reset()
- {
- const BOOL_ status = boost::detail::winapi::ResetEvent(handle_);
- if (status == 0)
- {
- const DWORD_ err = boost::detail::winapi::GetLastError();
- BOOST_SYNC_DETAIL_THROW(resource_error, (err)("boost::sync::event::reset failed in ResetEvent"));
- }
- }
-
- bool wait()
- {
- using namespace boost::detail::winapi;
-
- switch ( WaitForSingleObject(handle_, infinite) )
- {
- case wait_object_0:
- return true;
-
- case wait_failed:
- {
- const DWORD_ err = boost::detail::winapi::GetLastError();
- BOOST_SYNC_DETAIL_THROW(resource_error, (err)("boost::sync::event::wait failed in WaitForSingleObject"));
- }
-
- default:
- BOOST_ASSERT(false);
- return false;
- }
- }
-
- bool try_wait()
- {
- return do_try_wait_for( 0 );
- }
-
- template <class Rep, class Period>
- bool try_wait_for(const chrono::duration<Rep, Period> & rel_time)
- {
- return do_try_wait_for(static_cast< DWORD_ >(chrono::duration_cast<chrono::milliseconds>( rel_time ).count()));
- }
-
- template <class Clock, class Duration>
- bool try_wait_until(const chrono::time_point<Clock, Duration> & timeout )
- {
- typename Clock::time_point c_now = Clock::now();
- return try_wait_for( timeout - c_now );
- }
-
-private:
- bool do_try_wait_for( DWORD_ milliseconds )
- {
- using namespace boost::detail::winapi;
-
- switch ( WaitForSingleObject(handle_, milliseconds) )
- {
- case wait_object_0:
- return true;
-
- case wait_timeout:
- return false;
-
- case wait_failed:
- {
- const DWORD_ err = boost::detail::winapi::GetLastError();
- BOOST_SYNC_DETAIL_THROW(resource_error, (err)("boost::sync::event::do_try_wait_for failed in WaitForSingleObject"));
- }
-
- default:
- BOOST_ASSERT(false);
- return false;
- }
- }
-
- HANDLE_ handle_;
-};
-
-class auto_reset_event : win32_event_base
-{
-public:
- auto_reset_event() : win32_event_base(true) {}
-
- void post() { win32_event_base::post(); }
- void wait() { win32_event_base::wait(); }
- bool try_wait() { return win32_event_base::try_wait(); }
-
- template <typename Duration>
- bool try_wait_for(const Duration & duration) { return win32_event_base::try_wait_for( duration ); }
-
- template <typename TimePoint>
- bool try_wait_until(const TimePoint & timeout) { return win32_event_base::try_wait_until( timeout ); }
-};
-
-class manual_reset_event : win32_event_base
-{
-public:
- manual_reset_event() : win32_event_base(false) {}
-
- void post() { win32_event_base::post(); }
- void wait() { win32_event_base::wait(); }
- bool try_wait() { return win32_event_base::try_wait(); }
- void reset() { win32_event_base::reset(); }
-
- template <typename Duration>
- bool try_wait_for(const Duration & duration) { return win32_event_base::try_wait_for( duration ); }
-
- template <typename TimePoint>
- bool try_wait_until(const TimePoint & timeout) { return win32_event_base::try_wait_until( timeout ); }
-};
-
-
-}
-}
-}
-
-#include <boost/sync/detail/footer.hpp>
-
-#endif // BOOST_SYNC_DETAIL_EVENT_EVENT_WINDOWS_HPP_INCLUDED_

Added: trunk/boost/sync/detail/events/manual_reset_event_emulation.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/boost/sync/detail/events/manual_reset_event_emulation.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -0,0 +1,209 @@
+// event.hpp, condition variable emulation
+//
+// Copyright (C) 2013 Tim Blechmann
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_SYNC_DETAIL_EVENT_EVENT_EMULATION_HPP_INCLUDED_
+#define BOOST_SYNC_DETAIL_EVENT_EVENT_EMULATION_HPP_INCLUDED_
+
+#include <boost/sync/semaphore.hpp>
+
+// we use the semaphore implementation if we have native semaphores
+#ifndef BOOST_SYNC_SEMAPHORE_EMULATED
+#include <boost/sync/detail/event/event_autoreset_semaphore.hpp>
+#endif
+
+
+#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/thread/locks.hpp>
+
+#include <boost/sync/detail/config.hpp>
+//#include <boost/sync/locks/lock_guard.hpp>
+//#include <boost/sync/locks/unique_lock.hpp>
+#include <boost/sync/detail/header.hpp>
+
+#define BOOST_SYNC_EVENT_EMULATED
+
+namespace boost {
+namespace sync {
+BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {
+
+
+#ifdef BOOST_SYNC_SEMAPHORE_EMULATED
+
+class auto_reset_event
+{
+ BOOST_DELETED_FUNCTION(auto_reset_event(auto_reset_event const&));
+ BOOST_DELETED_FUNCTION(auto_reset_event& operator=(auto_reset_event const&));
+
+public:
+ auto_reset_event() BOOST_NOEXCEPT :
+ m_is_set(false)
+ {}
+
+ void post()
+ {
+ unique_lock<upgrade_mutex> lock(m_mutex);
+ bool already_signaled = m_is_set;
+ m_is_set = true;
+ if (!already_signaled)
+ m_cond.notify_one();
+ }
+
+ void wait()
+ {
+ upgrade_lock<upgrade_mutex> lock(m_mutex);
+
+ while (!m_is_set)
+ m_cond.wait(lock);
+
+ upgrade_to_unique_lock<upgrade_mutex> unique_lock(lock);
+ m_is_set = false;
+ }
+
+ void reset()
+ {
+ lock_guard<upgrade_mutex> lock(m_mutex);
+ m_is_set = false;
+ }
+
+ bool try_wait()
+ {
+ lock_guard<upgrade_mutex> lock(m_mutex);
+ const bool res = m_is_set;
+ if (res)
+ m_is_set = false;
+ return res;
+ }
+
+ template <class Duration>
+ bool try_wait_for(const Duration & duration)
+ {
+ upgrade_lock<upgrade_mutex> lock(m_mutex);
+
+ while (!m_is_set) {
+ if (m_cond.wait_for(lock, duration) == cv_status::timeout) {
+ if (!m_is_set)
+ return false;
+ break;
+ }
+ }
+
+ upgrade_to_unique_lock<upgrade_mutex> unique_lock(lock);
+ m_is_set = false;
+ return true;
+ }
+
+ template <typename TimePoint>
+ bool try_wait_until(const TimePoint & timeout)
+ {
+ upgrade_lock<upgrade_mutex> lock(m_mutex);
+
+ while (!m_is_set) {
+ if (m_cond.wait_until(lock, timeout) == cv_status::timeout) {
+ if (!m_is_set)
+ return false;
+ break;
+ }
+ }
+
+ upgrade_to_unique_lock<upgrade_mutex> unique_lock(lock);
+ m_is_set = false;
+ return true;
+ }
+
+private:
+ bool m_is_set;
+ upgrade_mutex m_mutex;
+ condition_variable_any m_cond;
+};
+
+#endif
+
+class manual_reset_event
+{
+ BOOST_DELETED_FUNCTION(manual_reset_event(manual_reset_event const&));
+ BOOST_DELETED_FUNCTION(manual_reset_event& operator=(manual_reset_event const&));
+
+public:
+ manual_reset_event() BOOST_NOEXCEPT :
+ m_is_set(false)
+ {}
+
+ void post()
+ {
+ unique_lock<upgrade_mutex> lock(m_mutex);
+ bool already_signaled = m_is_set;
+ m_is_set = true;
+ m_cond.notify_all();
+ }
+
+ void wait()
+ {
+ upgrade_lock<upgrade_mutex> lock(m_mutex);
+
+ while (!m_is_set)
+ m_cond.wait(lock);
+ }
+
+ void reset()
+ {
+ lock_guard<upgrade_mutex> lock(m_mutex);
+ m_is_set = false;
+ }
+
+ bool try_wait()
+ {
+ lock_guard<upgrade_mutex> lock(m_mutex);
+ return m_is_set;
+ }
+
+ template <typename Duration>
+ bool try_wait_for(const Duration & duration)
+ {
+ upgrade_lock<upgrade_mutex> lock(m_mutex);
+
+ while (!m_is_set) {
+ if (m_cond.wait_for(lock, duration) == cv_status::timeout) {
+ if (!m_is_set)
+ return false;
+ break;
+ }
+ }
+
+ return true;
+ }
+
+ template <typename TimePoint>
+ bool try_wait_until(const TimePoint & timeout)
+ {
+ upgrade_lock<upgrade_mutex> lock(m_mutex);
+
+ while (!m_is_set) {
+ if (m_cond.wait_until(lock, timeout) == cv_status::timeout) {
+ if (!m_is_set)
+ return false;
+ break;
+ }
+ }
+
+ return true;
+ }
+
+private:
+ bool m_is_set;
+ upgrade_mutex m_mutex;
+ condition_variable_any m_cond;
+};
+
+}
+}
+}
+
+#include <boost/sync/detail/footer.hpp>
+
+#endif // BOOST_SYNC_DETAIL_EVENT_EVENT_EMULATION_HPP_INCLUDED_

Added: trunk/boost/sync/detail/events/manual_reset_event_futex.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/boost/sync/detail/events/manual_reset_event_futex.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -0,0 +1,209 @@
+// manual_reset_event_futex.hpp, futex-based event
+//
+// Copyright (C) 2013 Tim Blechmann
+// Copyright (C) 2013 Andrey Semashev
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_SYNC_DETAIL_EVENTS_MANUAL_RESET_EVENT_FUTEX_HPP_INCLUDED_
+#define BOOST_SYNC_DETAIL_EVENTS_MANUAL_RESET_EVENT_FUTEX_HPP_INCLUDED_
+
+#include <errno.h>
+#include <sys/time.h>
+
+#include <boost/assert.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <boost/sync/detail/config.hpp>
+#include <boost/sync/detail/atomic.hpp>
+#include <boost/sync/detail/pause.hpp>
+#include <boost/sync/detail/futex.hpp>
+#include <boost/sync/detail/time_traits.hpp>
+#include <boost/sync/detail/time_units.hpp>
+#include <boost/sync/detail/header.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
+namespace boost {
+
+namespace sync {
+
+BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {
+
+class manual_reset_event
+{
+ BOOST_DELETED_FUNCTION(manual_reset_event(manual_reset_event const&));
+ BOOST_DELETED_FUNCTION(manual_reset_event& operator= (manual_reset_event const&));
+
+public:
+ manual_reset_event() BOOST_NOEXCEPT : m_state(0)
+ {
+ }
+
+ void set() BOOST_NOEXCEPT
+ {
+ int old_state = m_state.exchange(1, detail::atomic_ns::memory_order_release); // set state
+ if (old_state == 0)
+ sync::detail::linux_::futex_broadcast(reinterpret_cast< int* >(&m_state)); // wake all threads
+ }
+
+ void reset() BOOST_NOEXCEPT
+ {
+ m_state.store(0, detail::atomic_ns::memory_order_release);
+ }
+
+ void wait() BOOST_NOEXCEPT
+ {
+ while (m_state.load(detail::atomic_ns::memory_order_acquire) == 0)
+ {
+ const int status = sync::detail::linux_::futex_wait(reinterpret_cast< int* >(&m_state), 0);
+ if (status == 0)
+ break;
+
+ switch (errno)
+ {
+ case EINTR: // signal received
+ case EWOULDBLOCK: // another thread has reset the event
+ continue;
+
+ default:
+ BOOST_ASSERT(false);
+ }
+ }
+ }
+
+ bool try_wait()
+ {
+ return m_state.load(detail::atomic_ns::memory_order_acquire) == 1;
+ }
+
+ template< typename Time >
+ typename enable_if_c< sync::detail::time_traits< Time >::is_specialized, bool >::type timed_wait(Time const& timeout)
+ {
+ return priv_timed_wait(sync::detail::time_traits< Time >::to_sync_unit(timeout));
+ }
+
+ template< typename Duration >
+ typename enable_if< detail::is_time_tag_of< Duration, detail::time_duration_tag >, bool >::type wait_for(Duration const& duration)
+ {
+ return priv_timed_wait(sync::detail::time_traits< Duration >::to_sync_unit(duration));
+ }
+
+ template< typename TimePoint >
+ typename enable_if< detail::is_time_tag_of< TimePoint, detail::time_point_tag >, bool >::type wait_until(TimePoint const& abs_time)
+ {
+ return priv_timed_wait(sync::detail::time_traits< TimePoint >::to_sync_unit(abs_time));
+ }
+
+private:
+ bool priv_timed_wait(sync::detail::system_time_point const& abs_timeout)
+ {
+ while (m_state.load(detail::atomic_ns::memory_order_acquire) == 0)
+ {
+ sync::detail::system_duration::native_type time_left = (abs_timeout - sync::detail::system_time_point::now()).get();
+ if (time_left <= 0)
+ return false;
+
+ struct ::timespec timeout;
+ // Check that system time resolution is nanoseconds
+ BOOST_STATIC_ASSERT(sync::detail::system_duration::subsecond_fraction == 1000000000u);
+ timeout.tv_sec = time_left / sync::detail::system_duration::subsecond_fraction;
+ timeout.tv_nsec = time_left % sync::detail::system_duration::subsecond_fraction;
+
+ // Note that futex timeout must be relative
+ const int status = sync::detail::linux_::futex_timedwait(reinterpret_cast< int* >(&m_state), 0, &timeout);
+ if (status == 0)
+ break;
+
+ switch (errno)
+ {
+ case ETIMEDOUT:
+ return false;
+
+ case EINTR: // signal received
+ case EWOULDBLOCK: // another thread has reset the event
+ continue;
+
+ default:
+ BOOST_ASSERT(false);
+ }
+ }
+
+ return true;
+ }
+
+ bool priv_timed_wait(sync::detail::system_duration dur)
+ {
+ if (m_state.load(detail::atomic_ns::memory_order_acquire) == 0)
+ {
+ sync::detail::system_duration::native_type time_left = dur.get();
+ if (time_left <= 0)
+ return false;
+
+ struct ::timespec timeout;
+ // Check that system time resolution is nanoseconds
+ BOOST_STATIC_ASSERT(sync::detail::system_duration::subsecond_fraction == 1000000000u);
+ timeout.tv_sec = time_left / sync::detail::system_duration::subsecond_fraction;
+ timeout.tv_nsec = time_left % sync::detail::system_duration::subsecond_fraction;
+ do
+ {
+ // Note that futex timeout must be relative
+ const int status = sync::detail::linux_::futex_timedwait(reinterpret_cast< int* >(&m_state), 0, &timeout);
+ if (status == 0)
+ break;
+
+ switch (errno)
+ {
+ case ETIMEDOUT:
+ return false;
+
+ case EINTR: // signal received
+ case EWOULDBLOCK: // another thread has reset the event
+ continue;
+
+ default:
+ BOOST_ASSERT(false);
+ }
+ }
+ while (m_state.load(detail::atomic_ns::memory_order_acquire) == 0);
+ }
+
+ return true;
+ }
+
+ template< typename TimePoint >
+ bool priv_timed_wait(sync::detail::chrono_time_point< TimePoint > const& t)
+ {
+ typedef TimePoint time_point;
+ typedef typename time_point::clock clock;
+ typedef typename time_point::duration duration;
+ time_point now = clock::now();
+ do
+ {
+ if (timed_wait(sync::detail::time_traits< duration >::to_sync_unit(t.get() - now)))
+ return true;
+ now = clock::now();
+ }
+ while (now < t.get());
+
+ return false;
+ }
+
+private:
+ BOOST_STATIC_ASSERT_MSG(sizeof(detail::atomic_ns::atomic< int >) == sizeof(int), "Boost.Sync: unexpected size of atomic< int >");
+ detail::atomic_ns::atomic< int > m_state;
+};
+
+} // namespace abi
+
+} // namespace sync
+
+} // namespace boost
+
+#include <boost/sync/detail/footer.hpp>
+
+#endif // BOOST_SYNC_DETAIL_EVENTS_MANUAL_RESET_EVENT_FUTEX_HPP_INCLUDED_

Copied and modified: trunk/boost/sync/detail/events/manual_reset_event_mach.hpp (from r86335, trunk/boost/sync/detail/event/event_mach.hpp)
==============================================================================
--- trunk/boost/sync/detail/event/event_mach.hpp Wed Oct 16 13:49:10 2013 (r86335, copy source)
+++ trunk/boost/sync/detail/events/manual_reset_event_mach.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -1,4 +1,4 @@
-// event.hpp, mach events
+// manual_reset_event_mach.hpp, mach events
 //
 // Copyright (C) 2013 Tim Blechmann
 // Copyright (C) 2013 Andrey Semashev
@@ -7,64 +7,46 @@
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#ifndef BOOST_SYNC_EVENT_DETAIL_DARWIN_EVENT_MACH_HPP
-#define BOOST_SYNC_EVENT_DETAIL_DARWIN_EVENT_MACH_HPP
+#ifndef BOOST_SYNC_DETAIL_EVENTS_MANUAL_RESET_EVENT_MACH_HPP_INCLUDED_
+#define BOOST_SYNC_DETAIL_EVENTS_MANUAL_RESET_EVENT_MACH_HPP_INCLUDED_
 
-// auto_reset_event is implemented via sync::semaphores:
-#include <boost/sync/detail/event/event_autoreset_semaphore.hpp>
-
-
-#include <cstddef>
-#include <boost/assert.hpp>
 #include <boost/cstdint.hpp>
-
+#include <boost/utility/enable_if.hpp>
 #include <boost/sync/detail/config.hpp>
 #include <boost/sync/detail/atomic.hpp>
-#include <boost/sync/detail/pause.hpp>
-#include <boost/sync/exceptions/resource_error.hpp>
-
-#include <mach/task.h>
-#include <mach/semaphore.h>
-#include <mach/mach_traps.h>
-#include <mach/mach_init.h>
-
+#include <boost/sync/detail/time_traits.hpp>
+#include <boost/sync/detail/semaphore/basic_semaphore_mach.hpp>
 #include <boost/sync/detail/header.hpp>
 
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
 namespace boost {
 
 namespace sync {
 
 BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {
 
-
 class manual_reset_event
 {
     BOOST_DELETED_FUNCTION(manual_reset_event(manual_reset_event const&))
     BOOST_DELETED_FUNCTION(manual_reset_event& operator=(manual_reset_event const&));
 
 public:
- manual_reset_event() BOOST_NOEXCEPT :
- m_state(0)
- {
- kern_return_t result = semaphore_create(mach_task_self(), &m_sem, SYNC_POLICY_FIFO, 0);
- BOOST_VERIFY(result == KERN_SUCCESS);
- }
-
- ~manual_reset_event() BOOST_NOEXCEPT
+ manual_reset_event() : m_state(0)
     {
- kern_return_t result = semaphore_destroy(mach_task_self(), m_sem);
- BOOST_VERIFY(result == KERN_SUCCESS);
     }
 
- void post() BOOST_NOEXCEPT
+ void set()
     {
- m_state.store( 1, detail::atomic_ns::memory_order_release );
- semaphore_signal_all( m_sem ); // wake all threads!& reset semaphore count
+ m_state.store(1, detail::atomic_ns::memory_order_release);
+ m_sem.post_all(); // wake all threads & reset semaphore count
     }
 
- void reset() BOOST_NOEXCEPT
+ void reset()
     {
- m_state = 0;
+ m_state.store(0, detail::atomic_ns::memory_order_release);
     }
 
     void wait() BOOST_NOEXCEPT
@@ -72,53 +54,49 @@
         if (m_state.load(detail::atomic_ns::memory_order_acquire) == 1)
             return;
 
- kern_return_t result = semaphore_wait( m_sem );
- BOOST_VERIFY (result == KERN_SUCCESS);
+ m_sem.wait();
     }
 
     bool try_wait() BOOST_NOEXCEPT
     {
- const mach_timespec_t immediate = {0, 0};
- return do_try_wait_until(immediate);
+ return m_state.load(detail::atomic_ns::memory_order_acquire) == 1;
     }
 
- template <class Rep, class Period>
- bool try_wait_for(const chrono::duration<Rep, Period> & duration) BOOST_NOEXCEPT
+ template< typename Time >
+ typename enable_if_c< sync::detail::time_traits< Time >::is_specialized, bool >::type timed_wait(Time const& t)
     {
- chrono::seconds seconds = chrono::duration_cast<chrono::seconds>(duration);
- chrono::nanoseconds nanoseconds = chrono::duration_cast<chrono::nanoseconds>(duration) - seconds;
-
- const mach_timespec_t mach_duration = { static_cast<unsigned int>(seconds.count()), static_cast<clock_res_t>(nanoseconds.count()) };
- return do_try_wait_until( mach_duration );
+ if (try_wait())
+ return true;
+ return m_sem.timed_wait(sync::detail::time_traits< Time >::to_sync_unit(t));
     }
 
- template <class Clock, class Duration>
- bool try_wait_until(const chrono::time_point<Clock, Duration> & timeout ) BOOST_NOEXCEPT
+ template< typename Duration >
+ typename enable_if< detail::is_time_tag_of< Duration, detail::time_duration_tag >, bool >::type wait_for(Duration const& duration)
     {
- return try_wait_for( timeout - Clock::now() );
+ if (try_wait())
+ return true;
+ return m_sem.timed_wait(sync::detail::time_traits< Duration >::to_sync_unit(duration));
     }
 
-private:
- bool do_try_wait_until (const mach_timespec_t & timeout)
+ template< typename TimePoint >
+ typename enable_if< detail::is_time_tag_of< TimePoint, detail::time_point_tag >, bool >::type wait_until(TimePoint const& abs_time)
     {
- if (m_state.load( detail::atomic_ns::memory_order_acquire ) == 1)
+ if (try_wait())
             return true;
-
- kern_return_t result = semaphore_timedwait( m_sem, timeout );
- if (result == KERN_SUCCESS)
- return true;
- else
- return false;
+ return m_sem.timed_wait(sync::detail::time_traits< TimePoint >::to_sync_unit(abs_time));
     }
 
- semaphore_t m_sem;
- detail::atomic_ns::atomic<int32_t> m_state;
+private:
+ sync::detail::mach::basic_semaphore m_sem;
+ sync::detail::atomic_ns::atomic< int32_t > m_state;
 };
 
-}
-}
-}
+} // namespace abi
+
+} // namespace sync
+
+} // namespace boost
 
 #include <boost/sync/detail/footer.hpp>
 
-#endif // BOOST_SYNC_EVENT_DETAIL_DARWIN_EVENT_MACH_HPP
+#endif // BOOST_SYNC_DETAIL_EVENTS_MANUAL_RESET_EVENT_MACH_HPP_INCLUDED_

Added: trunk/boost/sync/detail/events/manual_reset_event_windows.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/boost/sync/detail/events/manual_reset_event_windows.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -0,0 +1,74 @@
+// manual_reset_event_windows.hpp, win32 events
+//
+// Copyright (C) 2013 Tim Blechmann
+// Copyright (C) 2013 Andrey Semashev
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_SYNC_DETAIL_EVENTS_MANUAL_RESET_EVENT_WINDOWS_HPP_INCLUDED_
+#define BOOST_SYNC_DETAIL_EVENTS_MANUAL_RESET_EVENT_WINDOWS_HPP_INCLUDED_
+
+#include <boost/utility/enable_if.hpp>
+#include <boost/sync/detail/config.hpp>
+#include <boost/sync/detail/time_traits.hpp>
+#include <boost/sync/detail/events/basic_event_windows.hpp>
+#include <boost/sync/detail/header.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
+namespace boost {
+
+namespace sync {
+
+BOOST_SYNC_DETAIL_OPEN_ABI_NAMESPACE {
+
+class manual_reset_event
+{
+ BOOST_DELETED_FUNCTION(manual_reset_event(manual_reset_event const&))
+ BOOST_DELETED_FUNCTION(manual_reset_event& operator=(manual_reset_event const&))
+
+public:
+ manual_reset_event() : m_event(true)
+ {
+ }
+
+ void set() { m_event.set(); }
+ void reset() { m_event.reset(); }
+ void wait() { m_event.wait(); }
+ bool try_wait() { return m_event.try_wait(); }
+
+ template< typename Time >
+ typename enable_if_c< sync::detail::time_traits< Time >::is_specialized, bool >::type timed_wait(Time const& timeout)
+ {
+ return m_event.timed_wait(sync::detail::time_traits< Time >::to_sync_unit(timeout));
+ }
+
+ template< typename Duration >
+ typename enable_if< detail::is_time_tag_of< Duration, detail::time_duration_tag >, bool >::type wait_for(Duration const& duration)
+ {
+ return m_event.timed_wait(sync::detail::time_traits< Duration >::to_sync_unit(duration));
+ }
+
+ template< typename TimePoint >
+ typename enable_if< detail::is_time_tag_of< TimePoint, detail::time_point_tag >, bool >::type wait_until(TimePoint const& abs_time)
+ {
+ return m_event.timed_wait(sync::detail::time_traits< TimePoint >::to_sync_unit(abs_time));
+ }
+
+private:
+ sync::detail::windows::basic_event m_event;
+};
+
+} // namespace abi
+
+} // namespace sync
+
+} // namespace boost
+
+#include <boost/sync/detail/footer.hpp>
+
+#endif // BOOST_SYNC_DETAIL_EVENTS_MANUAL_RESET_EVENT_WINDOWS_HPP_INCLUDED_

Added: trunk/boost/sync/detail/semaphore/basic_semaphore_mach.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/boost/sync/detail/semaphore/basic_semaphore_mach.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -0,0 +1,183 @@
+// basic_semaphore_mach.hpp, mach semaphores
+//
+// Copyright (C) 2013 Tim Blechmann
+// Copyright (C) 2013 Andrey Semashev
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_SYNC_DETAIL_SEMAPHORE_BASIC_SEMAPHORE_MACH_HPP_INCLUDED_
+#define BOOST_SYNC_DETAIL_SEMAPHORE_BASIC_SEMAPHORE_MACH_HPP_INCLUDED_
+
+#include <mach/task.h>
+#include <mach/semaphore.h>
+#include <mach/mach_traps.h>
+#include <mach/mach_init.h>
+
+#include <boost/assert.hpp>
+#include <boost/cstdint.hpp>
+#include <boost/sync/detail/config.hpp>
+#include <boost/sync/detail/time_traits.hpp>
+#include <boost/sync/detail/time_units.hpp>
+#include <boost/sync/detail/throw_exception.hpp>
+#include <boost/sync/detail/system_error.hpp>
+#include <boost/sync/exceptions/resource_error.hpp>
+#include <boost/sync/exceptions/wait_error.hpp>
+#include <boost/sync/detail/header.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
+namespace boost {
+
+namespace sync {
+
+namespace detail {
+
+namespace mach {
+
+class basic_semaphore
+{
+ BOOST_DELETED_FUNCTION(basic_semaphore(basic_semaphore const&))
+ BOOST_DELETED_FUNCTION(basic_semaphore& operator=(basic_semaphore const&))
+
+public:
+ explicit basic_semaphore(unsigned int i = 0)
+ {
+ kern_return_t result = semaphore_create(mach_task_self(), &m_sem, SYNC_POLICY_FIFO, i);
+ if (result != KERN_SUCCESS)
+ BOOST_SYNC_DETAIL_THROW(resource_error, (sync::detail::system_ns::errc::not_enough_memory)("semaphore constructor failed in semaphore_create"));
+ }
+
+ ~basic_semaphore()
+ {
+ BOOST_VERIFY(semaphore_destroy(mach_task_self(), m_sem) == KERN_SUCCESS);
+ }
+
+ void post()
+ {
+ BOOST_VERIFY(semaphore_signal(m_sem) == KERN_SUCCESS);
+ }
+
+ void post_all()
+ {
+ BOOST_VERIFY(semaphore_signal_all(m_sem) == KERN_SUCCESS);
+ }
+
+ void wait()
+ {
+ kern_return_t result = semaphore_wait(m_sem);
+ if (BOOST_UNLIKELY(result != KERN_SUCCESS))
+ {
+ switch (result)
+ {
+ case KERN_INVALID_ARGUMENT:
+ BOOST_SYNC_DETAIL_THROW(wait_error, (sync::detail::system_ns::errc::invalid_argument)("semaphore::wait failed: the specified semaphore is invalid."));
+
+ case KERN_TERMINATED:
+ BOOST_SYNC_DETAIL_THROW(wait_error, (sync::detail::system_ns::errc::invalid_argument)("semaphore::wait failed: the specified semaphore has been destroyed"));
+
+ case KERN_ABORTED:
+ default:
+ BOOST_SYNC_DETAIL_THROW(wait_error, (sync::detail::system_ns::errc::operation_canceled)("semaphore::wait failed: the wait operation has been aborted"));
+ }
+ }
+ }
+
+ bool try_wait()
+ {
+ const mach_timespec_t wait_time = { 0, 0 };
+ return priv_timed_wait(wait_time);
+ }
+
+ bool timed_wait(sync::detail::system_duration dur)
+ {
+ sync::detail::system_duration::native_type time_left = dur.get();
+ if (time_left < 0)
+ time_left = 0;
+ sync::detail::system_duration::native_type time_left_sec = time_left / system_duration::subsecond_fraction;
+ sync::detail::system_duration::native_type time_left_subsec = time_left % system_duration::subsecond_fraction;
+
+ enum
+ {
+ nanoseconds_fraction = 1000000000u,
+ conversion_ratio = static_cast< uint64_t >(nanoseconds_fraction) >= system_duration::subsecond_fraction ?
+ nanoseconds_fraction / system_duration::subsecond_fraction :
+ system_duration::subsecond_fraction / nanoseconds_fraction
+ };
+
+ const mach_timespec_t wait_time =
+ {
+ time_left_sec,
+ static_cast< uint64_t >(nanoseconds_fraction) >= system_duration::subsecond_fraction ?
+ time_left_subsec / conversion_ratio : time_left_subsec * conversion_ratio
+ };
+
+ return priv_timed_wait(wait_time);
+ }
+
+ bool timed_wait(sync::detail::system_time_point const& t)
+ {
+ return timed_wait(t - sync::detail::system_time_point::now());
+ }
+
+ template< typename TimePoint >
+ bool timed_wait(sync::detail::chrono_time_point< TimePoint > const& t)
+ {
+ typedef TimePoint time_point;
+ typedef typename time_point::clock clock;
+ typedef typename time_point::duration duration;
+ time_point now = clock::now();
+ while (now < t.get())
+ {
+ if (timed_wait(sync::detail::time_traits< duration >::to_sync_unit(t.get() - now)))
+ return true;
+ now = clock::now();
+ }
+ return false;
+ }
+
+private:
+ bool priv_timed_wait(const mach_timespec_t& wait_time)
+ {
+ kern_return_t result = semaphore_timedwait(m_sem, wait_time);
+
+ if (result == KERN_SUCCESS)
+ return true;
+
+ if (BOOST_UNLIKELY(result != KERN_OPERATION_TIMED_OUT))
+ {
+ switch (result)
+ {
+ case KERN_INVALID_ARGUMENT:
+ BOOST_SYNC_DETAIL_THROW(wait_error, (sync::detail::system_ns::errc::invalid_argument)("semaphore::timed_wait failed: the specified semaphore is invalid."));
+
+ case KERN_TERMINATED:
+ BOOST_SYNC_DETAIL_THROW(wait_error, (sync::detail::system_ns::errc::invalid_argument)("semaphore::timed_wait failed: the specified semaphore has been destroyed"));
+
+ case KERN_ABORTED:
+ default:
+ BOOST_SYNC_DETAIL_THROW(wait_error, (sync::detail::system_ns::errc::operation_canceled)("semaphore::timed_wait failed: the wait operation has been aborted"));
+ }
+ }
+
+ return false;
+ }
+
+private:
+ semaphore_t m_sem;
+};
+
+} // namespace mach
+
+} // namespace detail
+
+} // namespace sync
+
+} // namespace boost
+
+#include <boost/sync/detail/footer.hpp>
+
+#endif // BOOST_SYNC_DETAIL_SEMAPHORE_BASIC_SEMAPHORE_MACH_HPP_INCLUDED_

Modified: trunk/boost/sync/detail/semaphore/semaphore_emulation.hpp
==============================================================================
--- trunk/boost/sync/detail/semaphore/semaphore_emulation.hpp Fri Oct 18 07:40:46 2013 (r86350)
+++ trunk/boost/sync/detail/semaphore/semaphore_emulation.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -68,12 +68,12 @@
     }
 
     template< typename Time >
- typename enable_if_c< sync::detail::time_traits< Time >::is_specialized, bool >::type timed_wait(Time const& t)
+ typename enable_if_c< sync::detail::time_traits< Time >::is_specialized, bool >::type timed_wait(Time const& timeout)
     {
         sync::unique_lock< sync::mutex > lock(m_mutex);
         while (m_count == 0)
         {
- if (!m_cond.timed_wait(lock, t))
+ if (!m_cond.timed_wait(lock, timeout))
             {
                 if (m_count == 0)
                     return false;

Modified: trunk/boost/sync/detail/semaphore/semaphore_mach.hpp
==============================================================================
--- trunk/boost/sync/detail/semaphore/semaphore_mach.hpp Fri Oct 18 07:40:46 2013 (r86350)
+++ trunk/boost/sync/detail/semaphore/semaphore_mach.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -10,21 +10,10 @@
 #ifndef BOOST_SYNC_DETAIL_SEMAPHORE_SEMAPHORE_MACH_HPP_INCLUDED_
 #define BOOST_SYNC_DETAIL_SEMAPHORE_SEMAPHORE_MACH_HPP_INCLUDED_
 
-#include <mach/task.h>
-#include <mach/semaphore.h>
-#include <mach/mach_traps.h>
-#include <mach/mach_init.h>
-
-#include <boost/assert.hpp>
-#include <boost/cstdint.hpp>
 #include <boost/utility/enable_if.hpp>
 #include <boost/sync/detail/config.hpp>
 #include <boost/sync/detail/time_traits.hpp>
-#include <boost/sync/detail/time_units.hpp>
-#include <boost/sync/detail/throw_exception.hpp>
-#include <boost/sync/detail/system_error.hpp>
-#include <boost/sync/exceptions/resource_error.hpp>
-#include <boost/sync/exceptions/wait_error.hpp>
+#include <boost/sync/detail/semaphore/basic_semaphore_mach.hpp>
 #include <boost/sync/detail/header.hpp>
 
 #ifdef BOOST_HAS_PRAGMA_ONCE
@@ -43,145 +32,34 @@
     BOOST_DELETED_FUNCTION(semaphore& operator=(semaphore const&))
 
 public:
- explicit semaphore(unsigned int i = 0)
- {
- kern_return_t result = semaphore_create(mach_task_self(), &m_sem, SYNC_POLICY_FIFO, i);
- if (result != KERN_SUCCESS)
- BOOST_SYNC_DETAIL_THROW(resource_error, (sync::detail::system_ns::errc::not_enough_memory)("semaphore constructor failed in semaphore_create"));
- }
-
- ~semaphore()
+ explicit semaphore(unsigned int i = 0) : m_sem(i)
     {
- kern_return_t result = semaphore_destroy(mach_task_self(), m_sem);
- BOOST_VERIFY(result == KERN_SUCCESS);
     }
 
- void post()
- {
- kern_return_t result = semaphore_signal(m_sem);
- BOOST_VERIFY(result == KERN_SUCCESS);
- }
-
- void wait()
- {
- kern_return_t result = semaphore_wait(m_sem);
- if (BOOST_UNLIKELY(result != KERN_SUCCESS))
- {
- switch (result)
- {
- case KERN_INVALID_ARGUMENT:
- BOOST_SYNC_DETAIL_THROW(wait_error, (sync::detail::system_ns::errc::invalid_argument)("semaphore::wait failed: the specified semaphore is invalid."));
-
- case KERN_TERMINATED:
- BOOST_SYNC_DETAIL_THROW(wait_error, (sync::detail::system_ns::errc::invalid_argument)("semaphore::wait failed: the specified semaphore has been destroyed"));
-
- case KERN_ABORTED:
- default:
- BOOST_SYNC_DETAIL_THROW(wait_error, (sync::detail::system_ns::errc::operation_canceled)("semaphore::wait failed: the wait operation has been aborted"));
- }
- }
- }
-
- bool try_wait()
- {
- const mach_timespec_t wait_time = { 0, 0 };
- return priv_timed_wait(wait_time);
- }
+ void post() { m_sem.post(); }
+ void wait() { m_sem.wait(); }
+ bool try_wait() { return m_sem.try_wait(); }
 
     template< typename Time >
     typename enable_if_c< sync::detail::time_traits< Time >::is_specialized, bool >::type timed_wait(Time const& t)
     {
- return priv_timed_wait(sync::detail::time_traits< Time >::to_sync_unit(t));
+ return m_sem.timed_wait(sync::detail::time_traits< Time >::to_sync_unit(t));
     }
 
     template< typename Duration >
     typename enable_if< detail::is_time_tag_of< Duration, detail::time_duration_tag >, bool >::type wait_for(Duration const& duration)
     {
- return priv_timed_wait(sync::detail::time_traits< Duration >::to_sync_unit(duration));
+ return m_sem.timed_wait(sync::detail::time_traits< Duration >::to_sync_unit(duration));
     }
 
     template< typename TimePoint >
     typename enable_if< detail::is_time_tag_of< TimePoint, detail::time_point_tag >, bool >::type wait_until(TimePoint const& abs_time)
     {
- return priv_timed_wait(sync::detail::time_traits< TimePoint >::to_sync_unit(abs_time));
- }
-
-private:
- bool priv_timed_wait(sync::detail::system_duration dur)
- {
- sync::detail::system_duration::native_type time_left = dur.get();
- if (time_left < 0)
- time_left = 0;
- sync::detail::system_duration::native_type time_left_sec = time_left / system_duration::subsecond_fraction;
- sync::detail::system_duration::native_type time_left_subsec = time_left % system_duration::subsecond_fraction;
-
- enum
- {
- nanoseconds_fraction = 1000000000u,
- conversion_ratio = static_cast< uint64_t >(nanoseconds_fraction) >= system_duration::subsecond_fraction ?
- nanoseconds_fraction / system_duration::subsecond_fraction :
- system_duration::subsecond_fraction / nanoseconds_fraction
- };
-
- const mach_timespec_t wait_time =
- {
- time_left_sec,
- static_cast< uint64_t >(nanoseconds_fraction) >= system_duration::subsecond_fraction ?
- time_left_subsec / conversion_ratio : time_left_subsec * conversion_ratio
- };
-
- return priv_timed_wait(wait_time);
- }
-
- bool priv_timed_wait(sync::detail::system_time_point const& t)
- {
- return priv_timed_wait(t - sync::detail::system_time_point::now());
- }
-
- template< typename TimePoint >
- bool priv_timed_wait(sync::detail::chrono_time_point< TimePoint > const& t)
- {
- typedef TimePoint time_point;
- typedef typename time_point::clock clock;
- typedef typename time_point::duration duration;
- time_point now = clock::now();
- while (now < t.get())
- {
- if (priv_timed_wait(sync::detail::time_traits< duration >::to_sync_unit(t.get() - now)))
- return true;
- now = clock::now();
- }
- return false;
- }
-
- bool priv_timed_wait(const mach_timespec_t& wait_time)
- {
- kern_return_t result = semaphore_timedwait(m_sem, wait_time);
-
- if (result == KERN_SUCCESS)
- return true;
-
- if (BOOST_UNLIKELY(result != KERN_OPERATION_TIMED_OUT))
- {
- switch (result)
- {
- case KERN_INVALID_ARGUMENT:
- BOOST_SYNC_DETAIL_THROW(wait_error, (sync::detail::system_ns::errc::invalid_argument)("semaphore::try_wait failed: the specified semaphore is invalid."));
-
- case KERN_TERMINATED:
- BOOST_SYNC_DETAIL_THROW(wait_error, (sync::detail::system_ns::errc::invalid_argument)("semaphore::try_wait failed: the specified semaphore has been destroyed"));
-
- case KERN_ABORTED:
- default:
- BOOST_SYNC_DETAIL_THROW(wait_error, (sync::detail::system_ns::errc::operation_canceled)("semaphore::try_wait failed: the wait operation has been aborted"));
- }
- }
-
- return false;
+ return m_sem.timed_wait(sync::detail::time_traits< TimePoint >::to_sync_unit(abs_time));
     }
 
 private:
- semaphore_t m_sem;
+ sync::detail::mach::basic_semaphore m_sem;
 };
 
 } // namespace posix

Modified: trunk/boost/sync/detail/semaphore/semaphore_windows.hpp
==============================================================================
--- trunk/boost/sync/detail/semaphore/semaphore_windows.hpp Fri Oct 18 07:40:46 2013 (r86350)
+++ trunk/boost/sync/detail/semaphore/semaphore_windows.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -111,11 +111,11 @@
 private:
     bool priv_timed_wait(sync::detail::system_duration t)
     {
- if (try_wait())
- return true;
-
         sync::detail::system_duration::native_type time_left = t.get();
- while (time_left > 0)
+ if (time_left < 0)
+ time_left = 0;
+
+ do
         {
             const boost::detail::winapi::DWORD_ dur = time_left > boost::detail::winapi::max_non_infinite_wait ?
                 boost::detail::winapi::max_non_infinite_wait : static_cast< boost::detail::winapi::DWORD_ >(time_left);
@@ -136,6 +136,7 @@
                 }
             }
         }
+ while (time_left > 0);
 
         return false;
     }
@@ -179,12 +180,14 @@
         typedef typename time_point::clock clock;
         typedef typename time_point::duration duration;
         time_point now = clock::now();
- while (now < t.get())
+ do
         {
             if (priv_timed_wait(sync::detail::time_traits< duration >::to_sync_unit(t.get() - now)))
                 return true;
             now = clock::now();
         }
+ while (now < t.get());
+
         return false;
     }
 

Added: trunk/boost/sync/detail/semaphore_config.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/boost/sync/detail/semaphore_config.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -0,0 +1,46 @@
+// semaphore_config.hpp
+//
+// Copyright (C) 2013 Tim Blechmann
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_SYNC_DETAIL_SEMAPHORE_CONFIG_HPP_INCLUDED_
+#define BOOST_SYNC_DETAIL_SEMAPHORE_CONFIG_HPP_INCLUDED_
+
+#include <boost/sync/detail/config.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
+#if defined(BOOST_SYNC_DETAIL_PLATFORM_MACH)
+
+// OSX
+#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_6
+#define BOOST_SYNC_DETAIL_USE_DISPATCH_SEMAPHORES
+#endif
+
+#elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
+
+// untested!
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_4_0
+#define BOOST_SYNC_DETAIL_USE_DISPATCH_SEMAPHORES
+#endif
+
+#endif
+
+#endif // defined(BOOST_SYNC_DETAIL_PLATFORM_MACH)
+
+#if !defined(BOOST_SYNC_DETAIL_USE_DISPATCH_SEMAPHORES) && defined(BOOST_HAS_UNISTD_H)
+#include <unistd.h>
+
+#if (_POSIX_SEMAPHORES - 0) >= 200112L
+#define BOOST_SYNC_DETAIL_USE_POSIX_SEMAPHORES
+#endif
+#endif // !defined(BOOST_SYNC_DETAIL_USE_DISPATCH_SEMAPHORES) && defined(BOOST_HAS_UNISTD_H)
+
+#endif // BOOST_SYNC_DETAIL_SEMAPHORE_CONFIG_HPP_INCLUDED_

Modified: trunk/boost/sync/detail/time_units.hpp
==============================================================================
--- trunk/boost/sync/detail/time_units.hpp Fri Oct 18 07:40:46 2013 (r86350)
+++ trunk/boost/sync/detail/time_units.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -1,5 +1,5 @@
 /*
- * Copyright Andrey Semashev 2013.
+ * Copyright Andrey Semashev 2013.
  * Distributed under the Boost Software License, Version 1.0.
  * (See accompanying file LICENSE_1_0.txt or copy at
  * http://www.boost.org/LICENSE_1_0.txt)
@@ -39,12 +39,12 @@
 public:
     typedef int64_t native_type;
 
-#if defined(BOOST_SYNC_DETAIL_PLATFORM_PTHREAD)
- // The native duration is in nanoseconds
- static BOOST_CONSTEXPR_OR_CONST uint64_t subsecond_fraction = 1000000000u;
-#elif defined(BOOST_SYNC_DETAIL_PLATFORM_WINAPI)
+#if defined(BOOST_SYNC_DETAIL_PLATFORM_WINAPI)
     // The native duration is in milliseconds
     static BOOST_CONSTEXPR_OR_CONST uint64_t subsecond_fraction = 1000u;
+#else
+ // The native duration is in nanoseconds
+ static BOOST_CONSTEXPR_OR_CONST uint64_t subsecond_fraction = 1000000000u;
 #endif
 
 private:
@@ -83,64 +83,50 @@
     }
 };
 
-#if defined(BOOST_SYNC_DETAIL_PLATFORM_PTHREAD)
+#if defined(BOOST_SYNC_DETAIL_PLATFORM_WINAPI)
 
 class system_time_point
 {
 public:
- typedef struct ::timespec native_type;
- // The native subsecond precision is nanoseconds
- static BOOST_CONSTEXPR_OR_CONST uint64_t subsecond_fraction = system_duration::subsecond_fraction;
+ typedef uint64_t native_type;
+ // The native subsecond precision is 100 nanoseconds
+ static BOOST_CONSTEXPR_OR_CONST uint64_t subsecond_fraction = 10000000u;
 
 private:
- //! Time, since 1970-Jan-01
- native_type m_value;
+ //! 100 nanosecond units since 1601-Jan-01 (i.e. equivalent to FILETIME)
+ uint64_t m_value;
 
 public:
- BOOST_CONSTEXPR system_time_point() BOOST_NOEXCEPT : m_value() {}
- explicit system_time_point(time_t t, unsigned int subsecond = 0) BOOST_NOEXCEPT
+ BOOST_CONSTEXPR system_time_point() BOOST_NOEXCEPT : m_value(0) {}
+ explicit system_time_point(time_t t, unsigned int subsecond = 0) BOOST_NOEXCEPT :
+ m_value(static_cast< uint64_t >(t) * subsecond_fraction + subsecond + 116444736000000000ull)
     {
- m_value.tv_sec = t;
- m_value.tv_nsec = subsecond;
     }
 
     //! Creates time point from duration since 1970-Jan-01
- explicit system_time_point(system_duration dur) BOOST_NOEXCEPT
+ explicit system_time_point(system_duration dur) BOOST_NOEXCEPT :
+ m_value(dur.get() * 10000u + 116444736000000000ull)
     {
- m_value.tv_sec = dur.get() / subsecond_fraction;
- m_value.tv_nsec = dur.get() % subsecond_fraction;
     }
 
     native_type const& get() const BOOST_NOEXCEPT { return m_value; }
 
     static system_time_point now() BOOST_NOEXCEPT
     {
-#if defined(BOOST_HAS_CLOCK_GETTIME)
- system_time_point t;
- ::clock_gettime(CLOCK_REALTIME, &t.m_value);
- return t;
-#else
- return system_time_point(::time(0));
-#endif
+ system_time_point res;
+ boost::detail::winapi::GetSystemTimeAsFileTime(reinterpret_cast< boost::detail::winapi::FILETIME_* >(&res.m_value));
+ return res;
     }
 
     system_time_point& operator+= (system_duration const& dur) BOOST_NOEXCEPT
     {
- int64_t nsec = static_cast< int64_t >(m_value.tv_nsec) + dur.get();
- int64_t tv_nsec = nsec % system_duration::subsecond_fraction;
- if (tv_nsec < 0)
- {
- tv_nsec += subsecond_fraction;
- --m_value.tv_sec;
- }
- m_value.tv_nsec = tv_nsec;
- m_value.tv_sec += nsec / system_duration::subsecond_fraction;
-
+ m_value += dur.get() * 10000u;
         return *this;
     }
     system_time_point& operator-= (system_duration const& dur) BOOST_NOEXCEPT
     {
- return operator+= (-dur);
+ m_value -= dur.get() * 10000u;
+ return *this;
     }
 
     friend system_time_point operator+ (system_time_point left, system_duration const& right) BOOST_NOEXCEPT
@@ -156,56 +142,68 @@
 
     friend system_duration operator- (system_time_point const& left, system_time_point const& right) BOOST_NOEXCEPT
     {
- int64_t seconds = static_cast< int64_t >(left.m_value.tv_sec) - static_cast< int64_t >(right.m_value.tv_sec);
- int64_t nseconds = static_cast< int64_t >(left.m_value.tv_nsec) - static_cast< int64_t >(right.m_value.tv_nsec);
- return system_duration(seconds * system_duration::subsecond_fraction + nseconds);
+ return system_duration(static_cast< system_duration::native_type >(left.m_value - right.m_value) / 10000u);
     }
 };
 
-#elif defined(BOOST_SYNC_DETAIL_PLATFORM_WINAPI)
+#else
 
 class system_time_point
 {
 public:
- typedef uint64_t native_type;
- // The native subsecond precision is 100 nanoseconds
- static BOOST_CONSTEXPR_OR_CONST uint64_t subsecond_fraction = 10000000u;
+ typedef struct ::timespec native_type;
+ // The native subsecond precision is nanoseconds
+ static BOOST_CONSTEXPR_OR_CONST uint64_t subsecond_fraction = system_duration::subsecond_fraction;
 
 private:
- //! 100 nanosecond units since 1601-Jan-01 (i.e. equivalent to FILETIME)
- uint64_t m_value;
+ //! Time, since 1970-Jan-01
+ native_type m_value;
 
 public:
- BOOST_CONSTEXPR system_time_point() BOOST_NOEXCEPT : m_value(0) {}
- explicit system_time_point(time_t t, unsigned int subsecond = 0) BOOST_NOEXCEPT :
- m_value(static_cast< uint64_t >(t) * subsecond_fraction + subsecond + 116444736000000000ull)
+ BOOST_CONSTEXPR system_time_point() BOOST_NOEXCEPT : m_value() {}
+ explicit system_time_point(time_t t, unsigned int subsecond = 0) BOOST_NOEXCEPT
     {
+ m_value.tv_sec = t;
+ m_value.tv_nsec = subsecond;
     }
 
     //! Creates time point from duration since 1970-Jan-01
- explicit system_time_point(system_duration dur) BOOST_NOEXCEPT :
- m_value(dur.get() * 10000u + 116444736000000000ull)
+ explicit system_time_point(system_duration dur) BOOST_NOEXCEPT
     {
+ m_value.tv_sec = dur.get() / subsecond_fraction;
+ m_value.tv_nsec = dur.get() % subsecond_fraction;
     }
 
     native_type const& get() const BOOST_NOEXCEPT { return m_value; }
 
     static system_time_point now() BOOST_NOEXCEPT
     {
- system_time_point res;
- boost::detail::winapi::GetSystemTimeAsFileTime(reinterpret_cast< boost::detail::winapi::FILETIME_* >(&res.m_value));
- return res;
+#if defined(BOOST_HAS_CLOCK_GETTIME)
+ system_time_point t;
+ ::clock_gettime(CLOCK_REALTIME, &t.m_value);
+ return t;
+#else
+ return system_time_point(::time(0));
+#endif
     }
 
     system_time_point& operator+= (system_duration const& dur) BOOST_NOEXCEPT
     {
- m_value += dur.get() * 10000u;
+ int64_t nsec = static_cast< int64_t >(m_value.tv_nsec) + dur.get();
+ int64_t tv_nsec = nsec % system_duration::subsecond_fraction;
+ if (tv_nsec < 0)
+ {
+ tv_nsec += subsecond_fraction;
+ --m_value.tv_sec;
+ }
+ m_value.tv_nsec = tv_nsec;
+ m_value.tv_sec += nsec / system_duration::subsecond_fraction;
+
         return *this;
     }
     system_time_point& operator-= (system_duration const& dur) BOOST_NOEXCEPT
     {
- m_value -= dur.get() * 10000u;
- return *this;
+ return operator+= (-dur);
     }
 
     friend system_time_point operator+ (system_time_point left, system_duration const& right) BOOST_NOEXCEPT
@@ -221,7 +219,9 @@
 
     friend system_duration operator- (system_time_point const& left, system_time_point const& right) BOOST_NOEXCEPT
     {
- return system_duration(static_cast< system_duration::native_type >(left.m_value - right.m_value) / 10000u);
+ int64_t seconds = static_cast< int64_t >(left.m_value.tv_sec) - static_cast< int64_t >(right.m_value.tv_sec);
+ int64_t nseconds = static_cast< int64_t >(left.m_value.tv_nsec) - static_cast< int64_t >(right.m_value.tv_nsec);
+ return system_duration(seconds * system_duration::subsecond_fraction + nseconds);
     }
 };
 

Deleted: trunk/boost/sync/event.hpp
==============================================================================
--- trunk/boost/sync/event.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86350)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,215 +0,0 @@
-// event.hpp
-//
-// Copyright (C) 2013 Tim Blechmann
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_SYNC_EVENT_HPP
-#define BOOST_SYNC_EVENT_HPP
-
-#ifdef BOOST_SYNC_DETAIL_DOXYGEN
-
-class auto_reset_event
-{
-public:
- /**
- * \b Effects: Constructs an auto_reset_event object.
- *
- * \b Throws: if an error occurs.
- */
- auto_reset_event();
-
- auto_reset_event(auto_reset_event const&) = delete;
- auto_reset_event& operator= (auto_reset_event const&) = delete;
-
- /**
- * \b Effects: Destroys the auto_reset_event object.
- *
- * \b Precondition: No thread waits on this auto_reset_event.
- *
- * \b Throws: nothing.
- */
- ~auto_reset_event() noexcept;
-
- /**
- * \b Effects: Signals the auto_reset_event: the object remains signalled until one thread has finished waiting for this object.
- *
- * \b Memory Ordering: release
- *
- * \b Throws: if an error occurs.
- */
- void post();
-
- /**
- * \b Effects: If the auto_reset_event is set, the call returns immediately, otherwise it will block until the thread will be woken up
- * by. When a waiting thread is released, the state of the auto_reset_event is automatically reset to the unsignaled state.
- *
- * \b Memory Ordering: acquire
- *
- * \b Throws: if an error occurs.
- */
- void wait();
-
- /**
- * \b Effects: Tries to wait for the auto_reset_event. If successful, the state of the auto_reset_event us automatically set to the unsignaled state.
- *
- * \b Memory Ordering: acquire, if successful, relaxed otherwise
- *
- * \b Returns: True if the auto_reset_event had been signaled, False, if the call would be blocking or the auto_reset_event has not been signaled.
- *
- * \b Throws: if an error occurs.
- */
- bool try_wait();
-
- /**
- * \b Effects: Tries to wait for the auto_reset_event until a timeout occurs. If successful, the state of the auto_reset_event us automatically set to the unsignaled state.
- *
- * \b Memory Ordering: acquire, if successful, relaxed otherwise
- *
- * \b Returns: True if the auto_reset_event had been signaled, False, if the call would be blocking or the auto_reset_event has not been signaled.
- *
- * \b Throws: if an error occurs.
- */
- template <typename Duration>
- bool try_wait_for(const Duration & duration);
-
- /**
- * \b Effects: Tries to wait for the auto_reset_event for a certain duration. If successful, the state of the auto_reset_event us automatically set to the unsignaled state.
- *
- * \b Memory Ordering: acquire, if successful, relaxed otherwise
- *
- * \b Returns: True if the auto_reset_event had been signaled, False, if the call would be blocking or the auto_reset_event has not been signaled.
- *
- * \b Throws: if an error occurs.
- */
- template <typename TimePoint>
- bool try_wait_until(const TimePoint & timeout);
-};
-
-class manual_reset_event
-{
-public:
- /**
- * \b Effects: Constructs a manual_reset_event object.
- *
- * \b Throws: if an error occurs.
- */
- auto_reset_event();
-
- auto_reset_event(auto_reset_event const&) = delete;
- auto_reset_event& operator= (auto_reset_event const&) = delete;
-
- /**
- * \b Effects: Destroys the manual_reset_event object.
- *
- * \b Precondition: No thread waits on this manual_reset_event.
- *
- * \b Throws: nothing.
- */
- ~auto_reset_event() noexcept;
-
- /**
- * \b Effects: Signals the event object: the event is set and waiting threads will be released.
- *
- * \b Memory Ordering: release
- *
- * \b Throws: if an error occurs.
- */
- void post();
-
- /**
- * \b Effects: Waits for the event to be signaled.
- *
- * \b Memory Ordering: acquire
- *
- * \b Throws: if an error occurs.
- */
- void wait();
-
- /**
- * \b Effects: Resets the event to the unsignaled state.
- *
- * \b Throws: if an error occurs.
- */
- void reset();
-
- /**
- * \b Effects: Tries to waits for the event to be signaled.
- *
- * \b Memory Ordering: acquire, if successful, relaxed otherwise
- *
- * \b Returns: True if the event had been signaled, False, if the call would be blocking or the event has not been signaled.
- *
- * \b Throws: if an error occurs.
- */
- bool try_wait();
-
- /**
- * \b Effects: Waits for the event to be signaled.
- *
- * \b Memory Ordering: acquire, if successful, relaxed otherwise
- *
- * \b Returns: True if the event had been signaled, False, if the call would be blocking or the event has not been signaled.
- *
- * \b Throws: if an error occurs.
- */
- template <typename Duration>
- bool try_wait_for(const Duration & duration);
-
- /**
- * \b Effects: Waits for the event to be signaled.
- *
- * \b Memory Ordering: acquire, if successful, relaxed otherwise
- *
- * \b Returns: True if the event had been signaled, False, if the call would be blocking or the event has not been signaled.
- *
- * \b Throws: if an error occurs.
- */
- template <typename TimePoint>
- bool try_wait_until(const TimePoint & timeout);
-};
-
-
-#else // BOOST_SYNC_DETAIL_DOXYGEN
-
-#include <boost/sync/detail/config.hpp>
-
-#ifdef BOOST_HAS_PRAGMA_ONCE
-#pragma once
-#endif
-
-#if defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
-#include <Availability.h>
-
-// OSX
-#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
-
-// Check: do other mach-based platforms support mach semaphores?
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_7
-#define BOOST_SYNC_DETAIL_PLATFORM_MACH
-#endif
-
-#endif // __MAC_OS_X_VERSION_MIN_REQUIRED
-#endif // apple stuff
-
-#if defined(BOOST_SYNC_DETAIL_PLATFORM_WINAPI)
-#include <boost/sync/detail/event/event_windows.hpp>
-
-#elif defined(__linux__)
-#include <boost/sync/detail/event/event_futex.hpp>
-
-#elif defined(BOOST_SYNC_DETAIL_PLATFORM_MACH)
-#include <boost/sync/detail/event/event_mach.hpp>
-
-#else
-
-#include <boost/sync/detail/event/event_emulation.hpp>
-
-#endif
-
-#endif // BOOST_SYNC_DETAIL_DOXYGEN
-
-#endif // BOOST_SYNC_EVENT_HPP

Copied and modified: trunk/boost/sync/events.hpp (from r86335, trunk/boost/sync/event.hpp)
==============================================================================
--- trunk/boost/sync/event.hpp Wed Oct 16 13:49:10 2013 (r86335, copy source)
+++ trunk/boost/sync/events.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -1,178 +1,18 @@
-// event.hpp
-//
-// Copyright (C) 2013 Tim Blechmann
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
+/*
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * (C) Copyright 2013 Tim Blechmann
+ */
+/*!
+ * \file events.hpp
+ *
+ * \brief This header includes all event types.
+ */
 
-#ifndef BOOST_SYNC_EVENT_HPP
-#define BOOST_SYNC_EVENT_HPP
-
-#ifdef BOOST_SYNC_DETAIL_DOXYGEN
-
-class auto_reset_event
-{
-public:
- /**
- * \b Effects: Constructs an auto_reset_event object.
- *
- * \b Throws: if an error occurs.
- */
- auto_reset_event();
-
- auto_reset_event(auto_reset_event const&) = delete;
- auto_reset_event& operator= (auto_reset_event const&) = delete;
-
- /**
- * \b Effects: Destroys the auto_reset_event object.
- *
- * \b Precondition: No thread waits on this auto_reset_event.
- *
- * \b Throws: nothing.
- */
- ~auto_reset_event() noexcept;
-
- /**
- * \b Effects: Signals the auto_reset_event: the object remains signalled until one thread has finished waiting for this object.
- *
- * \b Memory Ordering: release
- *
- * \b Throws: if an error occurs.
- */
- void post();
-
- /**
- * \b Effects: If the auto_reset_event is set, the call returns immediately, otherwise it will block until the thread will be woken up
- * by. When a waiting thread is released, the state of the auto_reset_event is automatically reset to the unsignaled state.
- *
- * \b Memory Ordering: acquire
- *
- * \b Throws: if an error occurs.
- */
- void wait();
-
- /**
- * \b Effects: Tries to wait for the auto_reset_event. If successful, the state of the auto_reset_event us automatically set to the unsignaled state.
- *
- * \b Memory Ordering: acquire, if successful, relaxed otherwise
- *
- * \b Returns: True if the auto_reset_event had been signaled, False, if the call would be blocking or the auto_reset_event has not been signaled.
- *
- * \b Throws: if an error occurs.
- */
- bool try_wait();
-
- /**
- * \b Effects: Tries to wait for the auto_reset_event until a timeout occurs. If successful, the state of the auto_reset_event us automatically set to the unsignaled state.
- *
- * \b Memory Ordering: acquire, if successful, relaxed otherwise
- *
- * \b Returns: True if the auto_reset_event had been signaled, False, if the call would be blocking or the auto_reset_event has not been signaled.
- *
- * \b Throws: if an error occurs.
- */
- template <typename Duration>
- bool try_wait_for(const Duration & duration);
-
- /**
- * \b Effects: Tries to wait for the auto_reset_event for a certain duration. If successful, the state of the auto_reset_event us automatically set to the unsignaled state.
- *
- * \b Memory Ordering: acquire, if successful, relaxed otherwise
- *
- * \b Returns: True if the auto_reset_event had been signaled, False, if the call would be blocking or the auto_reset_event has not been signaled.
- *
- * \b Throws: if an error occurs.
- */
- template <typename TimePoint>
- bool try_wait_until(const TimePoint & timeout);
-};
-
-class manual_reset_event
-{
-public:
- /**
- * \b Effects: Constructs a manual_reset_event object.
- *
- * \b Throws: if an error occurs.
- */
- auto_reset_event();
-
- auto_reset_event(auto_reset_event const&) = delete;
- auto_reset_event& operator= (auto_reset_event const&) = delete;
-
- /**
- * \b Effects: Destroys the manual_reset_event object.
- *
- * \b Precondition: No thread waits on this manual_reset_event.
- *
- * \b Throws: nothing.
- */
- ~auto_reset_event() noexcept;
-
- /**
- * \b Effects: Signals the event object: the event is set and waiting threads will be released.
- *
- * \b Memory Ordering: release
- *
- * \b Throws: if an error occurs.
- */
- void post();
-
- /**
- * \b Effects: Waits for the event to be signaled.
- *
- * \b Memory Ordering: acquire
- *
- * \b Throws: if an error occurs.
- */
- void wait();
-
- /**
- * \b Effects: Resets the event to the unsignaled state.
- *
- * \b Throws: if an error occurs.
- */
- void reset();
-
- /**
- * \b Effects: Tries to waits for the event to be signaled.
- *
- * \b Memory Ordering: acquire, if successful, relaxed otherwise
- *
- * \b Returns: True if the event had been signaled, False, if the call would be blocking or the event has not been signaled.
- *
- * \b Throws: if an error occurs.
- */
- bool try_wait();
-
- /**
- * \b Effects: Waits for the event to be signaled.
- *
- * \b Memory Ordering: acquire, if successful, relaxed otherwise
- *
- * \b Returns: True if the event had been signaled, False, if the call would be blocking or the event has not been signaled.
- *
- * \b Throws: if an error occurs.
- */
- template <typename Duration>
- bool try_wait_for(const Duration & duration);
-
- /**
- * \b Effects: Waits for the event to be signaled.
- *
- * \b Memory Ordering: acquire, if successful, relaxed otherwise
- *
- * \b Returns: True if the event had been signaled, False, if the call would be blocking or the event has not been signaled.
- *
- * \b Throws: if an error occurs.
- */
- template <typename TimePoint>
- bool try_wait_until(const TimePoint & timeout);
-};
-
-
-#else // BOOST_SYNC_DETAIL_DOXYGEN
+#ifndef BOOST_SYNC_EVENTS_HPP_INCLUDED_
+#define BOOST_SYNC_EVENTS_HPP_INCLUDED_
 
 #include <boost/sync/detail/config.hpp>
 
@@ -180,36 +20,7 @@
 #pragma once
 #endif
 
-#if defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
-#include <Availability.h>
-
-// OSX
-#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
-
-// Check: do other mach-based platforms support mach semaphores?
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_7
-#define BOOST_SYNC_DETAIL_PLATFORM_MACH
-#endif
-
-#endif // __MAC_OS_X_VERSION_MIN_REQUIRED
-#endif // apple stuff
-
-#if defined(BOOST_SYNC_DETAIL_PLATFORM_WINAPI)
-#include <boost/sync/detail/event/event_windows.hpp>
-
-#elif defined(__linux__)
-#include <boost/sync/detail/event/event_futex.hpp>
-
-#elif defined(BOOST_SYNC_DETAIL_PLATFORM_MACH)
-#include <boost/sync/detail/event/event_mach.hpp>
-
-#else
-
-#include <boost/sync/detail/event/event_emulation.hpp>
-
-#endif
-
-#endif // BOOST_SYNC_DETAIL_DOXYGEN
+#include <boost/sync/events/auto_reset_event.hpp>
+#include <boost/sync/events/manual_reset_event.hpp>
 
-#endif // BOOST_SYNC_EVENT_HPP
+#endif // BOOST_SYNC_EVENTS_HPP_INCLUDED_

Added: trunk/boost/sync/events/auto_reset_event.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/boost/sync/events/auto_reset_event.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -0,0 +1,156 @@
+/*
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * (C) Copyright 2013 Tim Blechmann
+ */
+/*!
+ * \file auto_reset_event.hpp
+ *
+ * \brief This header defines an automatically reset event.
+ */
+
+#ifndef BOOST_SYNC_EVENTS_AUTO_RESET_EVENT_HPP_INCLUDED_
+#define BOOST_SYNC_EVENTS_AUTO_RESET_EVENT_HPP_INCLUDED_
+
+#ifdef BOOST_SYNC_DETAIL_DOXYGEN
+
+namespace boost {
+
+namespace sync {
+
+class auto_reset_event
+{
+public:
+ /**
+ * Constructs an event object in a non-signalled state.
+ *
+ * \b Throws: if an error occurs.
+ */
+ auto_reset_event();
+
+ auto_reset_event(auto_reset_event const&) = delete;
+ auto_reset_event& operator= (auto_reset_event const&) = delete;
+
+ /**
+ * Destroys the event object.
+ *
+ * \pre No threads are blocked on this object.
+ */
+ ~auto_reset_event();
+
+ /**
+ * If one or more threads are blocked on the event, releases one thread from its wait function. It is unspecified which thread is released.
+ * After releasing the thread the object is left in a non-signalled state. If no threads are blocked on the event, the object is left in a signalled state.
+ * The object remains signalled until exactly one thread completes waiting on this object. Posting an already signalled event has no effect.
+ *
+ * \b Memory Ordering: release
+ *
+ * \b Throws: if an error occurs.
+ */
+ void post();
+
+ /**
+ * If the event is signalled, the call makes the object non-signalled and returns. Otherwise the call blocks until the event is posted.
+ * When a waiting thread is released, the state of the event is automatically reset to the non-signaled state.
+ *
+ * \b Memory Ordering: acquire
+ *
+ * \b Throws: if an error occurs.
+ */
+ void wait();
+
+ /**
+ * Tries to wait for the event. If successful, the state of the event is automatically reset to the non-signaled state.
+ *
+ * \b Memory Ordering: acquire, if successful, relaxed otherwise
+ *
+ * \returns \c true if the event had been signalled and was reset to the non-signalled state by this call, otherwise \c false.
+ *
+ * \b Throws: if an error occurs.
+ */
+ bool try_wait();
+
+ /**
+ * If the event is signalled, the call makes the object non-signalled and returns. Otherwise the call blocks until the event is posted or the timeout expires.
+ * When a waiting thread is released due to a post, the state of the event is automatically reset to the non-signaled state.
+ *
+ * \b Memory Ordering: acquire, if successful, relaxed otherwise
+ *
+ * \param timeout The timeout for the operation to complete. The timeout can be specified either as an absolute time point or as a duration.
+ * In the latter case the time is measured according to the system clock.
+ *
+ * \returns \c true if the event had been signalled and was reset to the non-signalled state by this call, otherwise \c false.
+ *
+ * \b Throws: if an error occurs.
+ *
+ * \note In order to use this method, a supplementary header must be included from boost/sync/support to enable support for particular time units.
+ */
+ template <typename Time>
+ bool timed_wait(const Time & timeout);
+
+ /**
+ * If the event is signalled, the call makes the object non-signalled and returns. Otherwise the call blocks until the event is posted or the timeout expires.
+ * When a waiting thread is released due to a post, the state of the event is automatically reset to the non-signaled state.
+ *
+ * \b Memory Ordering: acquire, if successful, relaxed otherwise
+ *
+ * \param duration The timeout for the operation to complete. The timeout should be a duration, which is measured according to the system clock.
+ *
+ * \returns \c true if the event had been signalled and was reset to the non-signalled state by this call, otherwise \c false.
+ *
+ * \b Throws: if an error occurs.
+ *
+ * \note In order to use this method, a supplementary header must be included from boost/sync/support to enable support for particular time units.
+ */
+ template <typename Duration>
+ bool wait_for(const Duration & duration);
+
+ /**
+ * If the event is signalled, the call makes the object non-signalled and returns. Otherwise the call blocks until the event is posted or the timeout expires.
+ * When a waiting thread is released due to a post, the state of the event is automatically reset to the non-signaled state.
+ *
+ * \b Memory Ordering: acquire, if successful, relaxed otherwise
+ *
+ * \param timeout The timeout for the operation to complete. The timeout should be an absolute time point.
+ *
+ * \returns \c true if the event had been signalled and was reset to the non-signalled state by this call, otherwise \c false.
+ *
+ * \b Throws: if an error occurs.
+ *
+ * \note In order to use this method, a supplementary header must be included from boost/sync/support to enable support for particular time units.
+ */
+ template <typename TimePoint>
+ bool wait_until(const TimePoint & timeout);
+};
+
+} // namespace sync
+
+} // namespace boost
+
+#else // BOOST_SYNC_DETAIL_DOXYGEN
+
+#include <boost/sync/detail/config.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
+#if defined(BOOST_SYNC_DETAIL_PLATFORM_WINAPI)
+#include <boost/sync/detail/events/auto_reset_event_windows.hpp>
+#elif defined(BOOST_SYNC_DETAIL_PLATFORM_LINUX)
+#include <boost/sync/detail/events/auto_reset_event_futex.hpp>
+#else
+// Check to see that there's support for native semaphores
+#include <boost/sync/detail/semaphore_config.hpp>
+#if defined(BOOST_SYNC_DETAIL_USE_POSIX_SEMAPHORES)
+#include <boost/sync/detail/events/auto_reset_event_semaphore.hpp>
+#else
+#include <boost/sync/detail/events/auto_reset_event_emulation.hpp>
+#endif
+#endif
+
+#endif // BOOST_SYNC_DETAIL_DOXYGEN
+
+#endif // BOOST_SYNC_EVENTS_AUTO_RESET_EVENT_HPP_INCLUDED_

Added: trunk/boost/sync/events/manual_reset_event.hpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/boost/sync/events/manual_reset_event.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -0,0 +1,163 @@
+/*
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * (C) Copyright 2013 Tim Blechmann
+ */
+/*!
+ * \file manual_reset_event.hpp
+ *
+ * \brief This header defines a manually reset event.
+ */
+
+#ifndef BOOST_SYNC_EVENTS_MANUAL_RESET_EVENT_HPP_INCLUDED_
+#define BOOST_SYNC_EVENTS_MANUAL_RESET_EVENT_HPP_INCLUDED_
+
+#ifdef BOOST_SYNC_DETAIL_DOXYGEN
+
+namespace boost {
+
+namespace sync {
+
+class manual_reset_event
+{
+public:
+ /**
+ * Constructs an event object in a non-signalled state.
+ *
+ * \b Throws: if an error occurs.
+ */
+ manual_reset_event();
+
+ manual_reset_event(manual_reset_event const&) = delete;
+ manual_reset_event& operator= (manual_reset_event const&) = delete;
+
+ /**
+ * Destroys the event object.
+ *
+ * \pre No threads are blocked on this object.
+ */
+ ~manual_reset_event();
+
+ /**
+ * Sets the event object to the signalled state. While the event is set, any number of threads that are or would be blocked in one
+ * of the wait functions can be released while the event is in signalled state. Setting an already signalled event has no effect.
+ *
+ * \b Memory Ordering: release
+ *
+ * \b Throws: if an error occurs.
+ *
+ * \note If multiple threads are waiting on the event, this call does not guarantee that all these threads will be unblocked. It is
+ * possible that some of the woken threads resets the event to the non-signalled state before the other threads are unblocked.
+ */
+ void set();
+
+ /**
+ * Resets the event to the non-signaled state. Resetting a non-signalled event has no effect.
+ *
+ * \b Throws: if an error occurs.
+ */
+ void reset();
+
+ /**
+ * If the event is signalled, returns. Otherwise waits for the event to become signalled.
+ *
+ * \b Memory Ordering: acquire
+ *
+ * \b Throws: if an error occurs.
+ */
+ void wait();
+
+ /**
+ * Attempts to wait for the event to become signalled.
+ *
+ * \b Memory Ordering: acquire, if successful, relaxed otherwise
+ *
+ * \returns \c true if the event is signalled, otherwise \c false.
+ *
+ * \b Throws: if an error occurs.
+ */
+ bool try_wait();
+
+ /**
+ * If the event is signalled, the call returns. Otherwise the call blocks until the event is set to the signalled state or the timeout expires.
+ *
+ * \b Memory Ordering: acquire, if successful, relaxed otherwise
+ *
+ * \param timeout The timeout for the operation to complete. The timeout can be specified either as an absolute time point or as a duration.
+ * In the latter case the time is measured according to the system clock.
+ *
+ * \returns \c true if the event is signalled, otherwise \c false.
+ *
+ * \b Throws: if an error occurs.
+ *
+ * \note In order to use this method, a supplementary header must be included from boost/sync/support to enable support for particular time units.
+ */
+ template <typename Time>
+ bool timed_wait(const Time & timeout);
+
+ /**
+ * If the event is signalled, the call returns. Otherwise the call blocks until the event is set to the signalled state or the timeout expires.
+ *
+ * \b Memory Ordering: acquire, if successful, relaxed otherwise
+ *
+ * \param duration The timeout for the operation to complete. The timeout should be a duration, which is measured according to the system clock.
+ *
+ * \returns \c true if the event is signalled, otherwise \c false.
+ *
+ * \b Throws: if an error occurs.
+ *
+ * \note In order to use this method, a supplementary header must be included from boost/sync/support to enable support for particular time units.
+ */
+ template <typename Duration>
+ bool wait_for(const Duration & duration);
+
+ /**
+ * If the event is signalled, the call returns. Otherwise the call blocks until the event is set to the signalled state or the timeout expires.
+ *
+ * \b Memory Ordering: acquire, if successful, relaxed otherwise
+ *
+ * \param timeout The timeout for the operation to complete. The timeout should be an absolute time point.
+ *
+ * \returns \c true if the event is signalled, otherwise \c false.
+ *
+ * \b Throws: if an error occurs.
+ *
+ * \note In order to use this method, a supplementary header must be included from boost/sync/support to enable support for particular time units.
+ */
+ template <typename TimePoint>
+ bool wait_until(const TimePoint & timeout);
+};
+
+} // namespace sync
+
+} // namespace boost
+
+#else // BOOST_SYNC_DETAIL_DOXYGEN
+
+#include <boost/sync/detail/config.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
+#if defined(BOOST_SYNC_DETAIL_PLATFORM_WINAPI)
+#include <boost/sync/detail/events/manual_reset_event_windows.hpp>
+#elif defined(BOOST_SYNC_DETAIL_PLATFORM_LINUX)
+#include <boost/sync/detail/events/manual_reset_event_futex.hpp>
+#elif defined(BOOST_SYNC_DETAIL_PLATFORM_MACH)
+// Check to see that there's support for native semaphores
+#include <boost/sync/detail/semaphore_config.hpp>
+#if defined(BOOST_SYNC_DETAIL_USE_POSIX_SEMAPHORES) || defined(BOOST_SYNC_DETAIL_USE_DISPATCH_SEMAPHORES)
+#include <boost/sync/detail/events/manual_reset_event_mach.hpp>
+#else
+#include <boost/sync/detail/events/manual_reset_event_emulation.hpp>
+#endif
+#else
+#include <boost/sync/detail/events/manual_reset_event_emulation.hpp>
+#endif
+
+#endif // BOOST_SYNC_DETAIL_DOXYGEN
+
+#endif // BOOST_SYNC_EVENTS_MANUAL_RESET_EVENT_HPP_INCLUDED_

Modified: trunk/boost/sync/mutexes/mutex.hpp
==============================================================================
--- trunk/boost/sync/mutexes/mutex.hpp Fri Oct 18 07:40:46 2013 (r86350)
+++ trunk/boost/sync/mutexes/mutex.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -98,12 +98,10 @@
 #pragma once
 #endif
 
-#if defined(BOOST_SYNC_DETAIL_PLATFORM_PTHREAD)
-#include <boost/sync/detail/mutexes/mutex_posix.hpp>
-#elif defined(BOOST_SYNC_DETAIL_PLATFORM_WINAPI)
+#if defined(BOOST_SYNC_DETAIL_PLATFORM_WINAPI)
 #include <boost/sync/detail/mutexes/mutex_windows.hpp>
 #else
-#error Boost.Sync: Unsupported threading API
+#include <boost/sync/detail/mutexes/mutex_posix.hpp>
 #endif
 
 #endif // defined(BOOST_SYNC_DETAIL_DOXYGEN)

Modified: trunk/boost/sync/mutexes/timed_mutex.hpp
==============================================================================
--- trunk/boost/sync/mutexes/timed_mutex.hpp Fri Oct 18 07:40:46 2013 (r86350)
+++ trunk/boost/sync/mutexes/timed_mutex.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -146,12 +146,10 @@
 #pragma once
 #endif
 
-#if defined(BOOST_SYNC_DETAIL_PLATFORM_PTHREAD)
-#include <boost/sync/detail/mutexes/timed_mutex_posix.hpp>
-#elif defined(BOOST_SYNC_DETAIL_PLATFORM_WINAPI)
+#if defined(BOOST_SYNC_DETAIL_PLATFORM_WINAPI)
 #include <boost/sync/detail/mutexes/timed_mutex_windows.hpp>
 #else
-#error Boost.Sync: Unsupported threading API
+#include <boost/sync/detail/mutexes/timed_mutex_posix.hpp>
 #endif
 
 #endif // defined(BOOST_SYNC_DETAIL_DOXYGEN)

Modified: trunk/boost/sync/semaphore.hpp
==============================================================================
--- trunk/boost/sync/semaphore.hpp Fri Oct 18 07:40:46 2013 (r86350)
+++ trunk/boost/sync/semaphore.hpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -12,135 +12,137 @@
 #ifdef BOOST_SYNC_DETAIL_DOXYGEN
 
 namespace boost {
+
 namespace sync {
 
 class semaphore
 {
 public:
     /**
- * \b Effects: Constructs a semaphore object. The semaphore is initialized to `initial_count`, which is expected to be non-negative.
+ * Constructs a semaphore object.
      *
- * \b Throws: if an error occurs.
+ * \param initial_count The initial value of the semaphore. There may be an implementation-defined upper limit for the counter value,
+ * but it is safe to assume that values up to \c INT_MAX are supported.
      *
- * */
+ * \b Throws: if an error occurs.
+ */
     explicit semaphore(unsigned int initial_count = 0);
 
     /**
- * \b Precondition: No thread is waiting on the semaphore
+ * Destroys the object
      *
- * \b Effects: Destroys the object
- *
- * */
+ * \pre No thread is waiting on the semaphore
+ */
     ~semaphore();
 
     semaphore(semaphore const&) = delete;
     semaphore& operator= (semaphore const&) = delete;
 
     /**
- * \b Effects: Increments the semaphore count. If there are processes/threads blocked waiting for the semaphore, then one of these processes will return successfully from its wait function.
+ * Increments the semaphore counter. If one or multiple threads are blocked waiting for the semaphore, then one of these threads returns successfully
+ * from its wait function. It is unspecified which thread is released from the wait function.
      *
      * \b Memory Ordering: release
      *
+ * \note The implementation may have an upper limit for the semaphore counter, upon exceeding which the behavior is unspecified. It is safe to assume
+ * that values up to \c INT_MAX are supported.
+ *
      * \b Throws: if an error occurs.
- * */
+ */
     void post();
 
     /**
- * \b Effects: Decrements the semaphore. If the semaphore value is not greater than zero, then the calling process/thread blocks until it can decrement the counter.
+ * If the semaphore counter is greater than zero, decrements the counter and returns. If the semaphore value is not greater than zero,
+ * then the calling thread blocks until it can decrement the counter.
      *
      * \b Memory Ordering: acquire
      *
      * \b Throws: if an error occurs.
- * */
+ */
     void wait();
 
     /**
- * \b Effects: Decrements the semaphore if the semaphore's value is greater than zero and returns true. If the value is not greater than zero returns false.
+ * If the semaphore counter is greater than zero, decrements the counter and returns \c true. If the semaphore value is not greater than zero, returns \c false.
      *
      * \b Memory Ordering: acquire, if successful, relaxed otherwise
      *
      * \b Throws: if an error occurs.
- * */
+ */
     bool try_wait();
 
     /**
- * \b Effects: Decrements the semaphore if the semaphore's value is greater than zero and returns true. Otherwise, waits for the semaphore to the posted or the timeout expires. If the timeout expires, the function returns false. If the semaphore is posted the function returns true.
+ * If the semaphore counter is greater than zero, decrements the counter and returns \c true. If the semaphore value is not greater than zero,
+ * then the calling thread blocks until it can decrement the counter or the specified timeout expires.
+ *
+ * \b Memory Ordering: acquire, if successful, relaxed otherwise
+ *
+ * \param timeout The timeout for the operation to complete. The timeout can be specified either as an absolute time point or as a duration.
+ * In the latter case the time is measured according to the system clock.
+ *
+ * \returns If the timeout expires, the function returns \c false. If the semaphore counter is decremented, the function returns \c true.
+ *
+ * \b Throws: if an error occurs.
+ *
+ * \note In order to use this method, a supplementary header must be included from boost/sync/support to enable support for particular time units.
+ */
+ template <class Time>
+ bool timed_wait(const Time & timeout);
+
+ /**
+ * If the semaphore counter is greater than zero, decrements the counter and returns \c true. If the semaphore value is not greater than zero,
+ * then the calling thread blocks until it can decrement the counter or the specified timeout expires.
      *
      * \b Memory Ordering: acquire, if successful, relaxed otherwise
      *
+ * \param duration The timeout for the operation to complete. The timeout should be a duration, which is measured according to the system clock.
+ *
+ * \returns If the timeout expires, the function returns \c false. If the semaphore counter is decremented, the function returns \c true.
+ *
      * \b Throws: if an error occurs.
- * */
+ *
+ * \note In order to use this method, a supplementary header must be included from boost/sync/support to enable support for particular time units.
+ */
     template <class Duration>
- bool try_wait_for(const Duration & duration);
+ bool wait_for(const Duration & duration);
 
     /**
- * \b Effects: Decrements the semaphore if the semaphore's value is greater than zero and returns true. Otherwise, waits for the semaphore to the posted or the timeout expires. If the timeout expires, the function returns false. If the semaphore is posted the function returns true.
+ * If the semaphore counter is greater than zero, decrements the counter and returns \c true. If the semaphore value is not greater than zero,
+ * then the calling thread blocks until it can decrement the counter or the specified timeout expires.
      *
      * \b Memory Ordering: acquire, if successful, relaxed otherwise
      *
+ * \param timeout The timeout for the operation to complete. The timeout should be an absolute time point.
+ *
+ * \returns If the timeout expires, the function returns \c false. If the semaphore counter is decremented, the function returns \c true.
+ *
      * \b Throws: if an error occurs.
- * */
+ *
+ * \note In order to use this method, a supplementary header must be included from boost/sync/support to enable support for particular time units.
+ */
     template <class TimePoint>
- bool try_wait_until(const TimePoint & timeout);
+ bool wait_until(const TimePoint & timeout);
 };
 
-}
-}
+} // namespace sync
+
+} // namespace boost
 
 #else // BOOST_SYNC_DETAIL_DOXYGEN
 
-#include <boost/sync/detail/config.hpp>
+#include <boost/sync/detail/semaphore_config.hpp>
 
 #ifdef BOOST_HAS_PRAGMA_ONCE
 #pragma once
 #endif
 
-#ifdef BOOST_HAS_UNISTD_H
-#include <unistd.h>
-
-#if (_POSIX_SEMAPHORES - 0) >= 200112L
-#define BOOST_SYNC_DETAIL_USE_POSIX_SEMAPHORES
-#endif
-
-#endif // BOOST_HAS_UNISTD_H
-
-#if defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
-#include <Availability.h>
-
-// OSX
-#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_6
-#define BOOST_SYNC_DETAIL_USE_DISPATCH_SEMAPHORES
-#endif
-
-#endif // __MAC_OS_X_VERSION_MIN_REQUIRED
-
-// iOS
-#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
-
-// untested!
-#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_4_0
-#define BOOST_SYNC_DETAIL_USE_DISPATCH_SEMAPHORES
-#endif
-
-#endif // __IPHONE_OS_VERSION_MIN_REQUIRED
-
-#endif // !defined(BOOST_SYNC_DETAIL_USE_POSIX_SEMAPHORES) && defined(__APPLE__)
-
-
 #if defined(BOOST_SYNC_DETAIL_PLATFORM_WINAPI)
 #include <boost/sync/detail/semaphore/semaphore_windows.hpp>
-
 #elif defined(BOOST_SYNC_DETAIL_USE_DISPATCH_SEMAPHORES)
 #include <boost/sync/detail/semaphore/semaphore_dispatch.hpp>
-
 #elif defined(BOOST_SYNC_DETAIL_USE_POSIX_SEMAPHORES)
 #include <boost/sync/detail/semaphore/semaphore_posix.hpp>
-
 #else
 #include <boost/sync/detail/semaphore/semaphore_emulation.hpp>
-
 #endif
 
 #endif // BOOST_SYNC_DETAIL_DOXYGEN

Modified: trunk/libs/sync/test/run/event_test.cpp
==============================================================================
--- trunk/libs/sync/test/run/event_test.cpp Fri Oct 18 07:40:46 2013 (r86350)
+++ trunk/libs/sync/test/run/event_test.cpp 2013-10-18 10:00:03 EDT (Fri, 18 Oct 2013) (r86351)
@@ -5,8 +5,11 @@
 
 #include <boost/test/unit_test.hpp>
 
-#include <boost/thread.hpp>
-#include <boost/sync/event.hpp>
+#include <boost/bind.hpp>
+#include <boost/chrono.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/sync/events.hpp>
+#include <boost/sync/support/boost_chrono.hpp>
 
 #include <boost/typeof/typeof.hpp>
 
@@ -14,7 +17,7 @@
 {
     boost::sync::manual_reset_event ev;
 
- ev.post();
+ ev.set();
     ev.wait();
 
     BOOST_REQUIRE( ev.try_wait() == true );
@@ -31,7 +34,7 @@
 
     BOOST_REQUIRE( ev.try_wait() == false );
 
- ev.post();
+ ev.set();
 
     BOOST_REQUIRE( ev.try_wait() == true );
 }
@@ -51,12 +54,22 @@
     boost::sync::manual_reset_event ev;
 
     BOOST_REQUIRE( ev.try_wait() == false );
- ev.post();
+ ev.set();
     BOOST_REQUIRE( ev.try_wait() == true );
     ev.reset();
     BOOST_REQUIRE( ev.try_wait() == false );
 }
 
+inline void post_event(boost::sync::manual_reset_event& evt)
+{
+ evt.set();
+}
+
+inline void post_event(boost::sync::auto_reset_event& evt)
+{
+ evt.post();
+}
+
 template <typename EventType>
 struct event_wait_and_post_test
 {
@@ -69,7 +82,7 @@
     void wait_and_post()
     {
         boost::this_thread::sleep_for(boost::chrono::seconds(1));
- ev_.post();
+ (post_event)(ev_);
     }
 
     EventType ev_;
@@ -98,7 +111,7 @@
 
     BOOST_REQUIRE( ev.try_wait() == false );
 
- BOOST_REQUIRE(!ev.try_wait_for(chrono::milliseconds(500)));
+ BOOST_REQUIRE(!ev.wait_for(chrono::milliseconds(500)));
 
     BOOST_REQUIRE( ev.try_wait() == false );
 
@@ -110,9 +123,9 @@
     BOOST_REQUIRE( wait_time > chrono::milliseconds(450) );
     BOOST_REQUIRE( wait_time < chrono::milliseconds(1000) );
 
- ev.post();
+ ev.set();
 
- BOOST_REQUIRE(ev.try_wait_for(chrono::milliseconds(500)));
+ BOOST_REQUIRE(ev.wait_for(chrono::milliseconds(500)));
 }
 
 BOOST_AUTO_TEST_CASE(test_event_wait_until)
@@ -124,7 +137,7 @@
         BOOST_AUTO(now, chrono::system_clock::now());
         BOOST_AUTO(timeout, now + chrono::milliseconds(500));
 
- BOOST_REQUIRE(!ev.try_wait_until(timeout));
+ BOOST_REQUIRE(!ev.wait_until(timeout));
 
         BOOST_AUTO(end, chrono::system_clock::now());
         BOOST_AUTO(timeout_delta, end - timeout);
@@ -134,13 +147,13 @@
         BOOST_REQUIRE( timeout_delta < chrono::milliseconds(400) );
     }
 
- ev.post();
+ ev.set();
 
     {
         BOOST_AUTO(start, chrono::system_clock::now());
         BOOST_AUTO(timeout, start + chrono::milliseconds(500));
 
- BOOST_REQUIRE(ev.try_wait_until(timeout));
+ BOOST_REQUIRE(ev.wait_until(timeout));
 
         BOOST_AUTO(end, chrono::system_clock::now());
 


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