|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r85679 - in trunk/boost: detail/win sync sync/detail/darwin sync/detail/generic sync/detail/osx sync/detail/posix sync/detail/posix/mutexes sync/detail/windows sync/semaphore
From: andrey.semashev_at_[hidden]
Date: 2013-09-15 12:58:33
Author: andysem
Date: 2013-09-15 12:58:33 EDT (Sun, 15 Sep 2013)
New Revision: 85679
URL: http://svn.boost.org/trac/boost/changeset/85679
Log:
Moved semaphore implementation to details. Some minor fixes.
Added:
trunk/boost/sync/detail/darwin/
- copied from r85676, trunk/boost/sync/detail/osx/
trunk/boost/sync/detail/darwin/semaphore.hpp
- copied, changed from r85674, trunk/boost/sync/semaphore/semaphore_dispatch.hpp
trunk/boost/sync/detail/generic/
trunk/boost/sync/detail/generic/semaphore.hpp
- copied, changed from r85674, trunk/boost/sync/semaphore/semaphore_emulation.hpp
trunk/boost/sync/detail/posix/semaphore.hpp
- copied, changed from r85674, trunk/boost/sync/semaphore/semaphore_posix.hpp
trunk/boost/sync/detail/windows/semaphore.hpp
- copied, changed from r85674, trunk/boost/sync/semaphore/semaphore_win32.hpp
Deleted:
trunk/boost/sync/detail/osx/
trunk/boost/sync/semaphore/
Text files modified:
trunk/boost/detail/win/synchronization.hpp | 4 +
trunk/boost/sync/detail/darwin/semaphore.hpp | 47 +++++++++++++++--------
trunk/boost/sync/detail/generic/semaphore.hpp | 28 ++++++++++----
trunk/boost/sync/detail/posix/mutexes/mutex.hpp | 3 +
trunk/boost/sync/detail/posix/mutexes/timed_mutex.hpp | 5 +-
trunk/boost/sync/detail/posix/semaphore.hpp | 55 +++++++++++++++++-----------
trunk/boost/sync/detail/windows/semaphore.hpp | 76 ++++++++++++++++++++++++---------------
trunk/boost/sync/semaphore.hpp | 62 +++++++++++++++++++++++--------
8 files changed, 183 insertions(+), 97 deletions(-)
Modified: trunk/boost/detail/win/synchronization.hpp
==============================================================================
--- trunk/boost/detail/win/synchronization.hpp Sun Sep 15 12:56:43 2013 (r85678)
+++ trunk/boost/detail/win/synchronization.hpp 2013-09-15 12:58:33 EDT (Sun, 15 Sep 2013) (r85679)
@@ -45,8 +45,9 @@
using ::ResetEvent;
using ::WaitForMultipleObjects;
using ::WaitForSingleObject;
- using ::QueueUserAPC;
+ using ::QueueUserAPC;
+ static const DWORD_ infinite = INFINITE;
static const DWORD_ wait_abandoned = WAIT_ABANDONED;
static const DWORD_ wait_object_0 = WAIT_OBJECT_0;
static const DWORD_ wait_timeout = WAIT_TIMEOUT;
@@ -122,6 +123,7 @@
using ::SetEvent;
using ::ResetEvent;
+ static const DWORD_ infinite = (DWORD_)0xFFFFFFFF;
static const DWORD_ wait_abandoned = 0x00000080L;
static const DWORD_ wait_object_0 = 0x00000000L;
static const DWORD_ wait_timeout = 0x00000102L;
Copied and modified: trunk/boost/sync/detail/darwin/semaphore.hpp (from r85674, trunk/boost/sync/semaphore/semaphore_dispatch.hpp)
==============================================================================
--- trunk/boost/sync/semaphore/semaphore_dispatch.hpp Sun Sep 15 07:05:46 2013 (r85674, copy source)
+++ trunk/boost/sync/detail/darwin/semaphore.hpp 2013-09-15 12:58:33 EDT (Sun, 15 Sep 2013) (r85679)
@@ -6,19 +6,30 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_SYNC_SEMAPHORE_SEMAPHORE_DISPATCH_HPP
-#define BOOST_SYNC_SEMAPHORE_SEMAPHORE_DISPATCH_HPP
+#ifndef BOOST_SYNC_DETAIL_DARWIN_SEMAPHORE_HPP_INCLUDED_
+#define BOOST_SYNC_DETAIL_DARWIN_SEMAPHORE_HPP_INCLUDED_
+#include <cstddef>
#include <dispatch/dispatch.h>
-#include <boost/thread/exceptions.hpp>
+#include <boost/throw_exception.hpp>
+#include <boost/sync/detail/config.hpp>
+#include <boost/sync/detail/system_error.hpp>
+#include <boost/sync/exceptions/resource_error.hpp>
#ifdef BOOST_SYNC_USES_CHRONO
#include <boost/chrono/system_clocks.hpp>
#include <boost/chrono/ceil.hpp>
#endif
+#include <boost/sync/detail/header.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
namespace boost {
+
namespace sync {
class semaphore
@@ -27,32 +38,31 @@
BOOST_DELETED_FUNCTION(semaphore& operator=(semaphore const&))
public:
- semaphore(int i=0)
+ explicit semaphore(unsigned int i = 0)
{
- BOOST_ASSERT_MSG(i >= 0, "boost::sync::semaphore constructor called with negative count");
- sem = dispatch_semaphore_create(i);
- if (sem == NULL)
- boost::throw_exception(thread_resource_error(system::errc::not_enough_memory, "boost::sync::semaphore constructor failed in dispatch_semaphore_create"));
+ m_sem = dispatch_semaphore_create(i);
+ if (m_sem == NULL)
+ BOOST_THROW_EXCEPTION(resource_error(sync::detail::system_namespace::errc::not_enough_memory, "boost::sync::semaphore constructor failed in dispatch_semaphore_create"));
}
~semaphore()
{
- dispatch_release(sem);
+ dispatch_release(m_sem);
}
void post()
{
- dispatch_semaphore_signal(sem);
+ dispatch_semaphore_signal(m_sem);
}
void wait()
{
- dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
+ dispatch_semaphore_wait(m_sem, DISPATCH_TIME_FOREVER);
}
bool try_wait(void)
{
- const long status = dispatch_semaphore_wait(sem, DISPATCH_TIME_NOW);
+ const long status = dispatch_semaphore_wait(m_sem, DISPATCH_TIME_NOW);
return status == 0;
}
@@ -90,17 +100,20 @@
private:
bool do_wait_lock_until(const dispatch_time_t timeout)
{
- const long status = dispatch_semaphore_wait(sem, timeout);
+ const long status = dispatch_semaphore_wait(m_sem, timeout);
return status == 0;
}
#endif // BOOST_SYNC_USES_CHRONO
private:
- dispatch_semaphore_t sem;
+ dispatch_semaphore_t m_sem;
};
-}
-}
+} // namespace sync
+
+} // namespace boost
+
+#include <boost/sync/detail/footer.hpp>
-#endif // BOOST_SYNC_SEMAPHORE_SEMAPHORE_DISPATCH_HPP
+#endif // BOOST_SYNC_DETAIL_DARWIN_SEMAPHORE_HPP_INCLUDED_
Copied and modified: trunk/boost/sync/detail/generic/semaphore.hpp (from r85674, trunk/boost/sync/semaphore/semaphore_emulation.hpp)
==============================================================================
--- trunk/boost/sync/semaphore/semaphore_emulation.hpp Sun Sep 15 07:05:46 2013 (r85674, copy source)
+++ trunk/boost/sync/detail/generic/semaphore.hpp 2013-09-15 12:58:33 EDT (Sun, 15 Sep 2013) (r85679)
@@ -6,21 +6,29 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_SYNC_SEMAPHORE_SEMAPHORE_EMULATION_HPP
-#define BOOST_SYNC_SEMAPHORE_SEMAPHORE_EMULATION_HPP
+#ifndef BOOST_SYNC_DETAIL_GENERIC_SEMAPHORE_HPP_INCLUDED_
+#define BOOST_SYNC_DETAIL_GENERIC_SEMAPHORE_HPP_INCLUDED_
#include <boost/bind.hpp>
-#include <boost/noncopyable.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
+#include <boost/sync/detail/config.hpp>
+
#ifdef BOOST_SYNC_USES_CHRONO
#include <boost/chrono/system_clocks.hpp>
#include <boost/chrono/ceil.hpp>
#endif
+#include <boost/sync/detail/header.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
namespace boost {
+
namespace sync {
class semaphore
@@ -29,10 +37,9 @@
BOOST_DELETED_FUNCTION(semaphore& operator=(semaphore const&))
public:
- semaphore(int i=0):
- m_count(i)
+ explicit semaphore(unsigned int i = 0) :
+ m_count(i)
{
- BOOST_ASSERT_MSG(i >= 0, "boost::sync::semaphore constructor called with negative count");
}
void post(void)
@@ -87,7 +94,10 @@
boost::condition_variable m_cond;
};
-}
-}
+} // namespace sync
+
+} // namespace boost
+
+#include <boost/sync/detail/footer.hpp>
-#endif // BOOST_SYNC_SEMAPHORE_SEMAPHORE_EMULATION_HPP
+#endif // BOOST_SYNC_DETAIL_GENERIC_SEMAPHORE_HPP_INCLUDED_
Modified: trunk/boost/sync/detail/posix/mutexes/mutex.hpp
==============================================================================
--- trunk/boost/sync/detail/posix/mutexes/mutex.hpp Sun Sep 15 12:56:43 2013 (r85678)
+++ trunk/boost/sync/detail/posix/mutexes/mutex.hpp 2013-09-15 12:58:33 EDT (Sun, 15 Sep 2013) (r85679)
@@ -17,6 +17,7 @@
#ifndef BOOST_SYNC_DETAIL_POSIX_MUTEXES_MUTEX_HPP_INCLUDED_
#define BOOST_SYNC_DETAIL_POSIX_MUTEXES_MUTEX_HPP_INCLUDED_
+#include <cstddef>
#include <boost/assert.hpp>
#include <boost/throw_exception.hpp>
#include <boost/sync/exceptions/lock_error.hpp>
@@ -62,7 +63,7 @@
#else // defined(PTHREAD_MUTEX_INITIALIZER)
mutex()
{
- int const res = pthread_mutex_init(&m_mutex, 0);
+ int const res = pthread_mutex_init(&m_mutex, NULL);
if (res)
{
BOOST_THROW_EXCEPTION(resource_error(res, "boost:: mutex constructor failed in pthread_mutex_init"));
Modified: trunk/boost/sync/detail/posix/mutexes/timed_mutex.hpp
==============================================================================
--- trunk/boost/sync/detail/posix/mutexes/timed_mutex.hpp Sun Sep 15 12:56:43 2013 (r85678)
+++ trunk/boost/sync/detail/posix/mutexes/timed_mutex.hpp 2013-09-15 12:58:33 EDT (Sun, 15 Sep 2013) (r85679)
@@ -18,6 +18,7 @@
#define BOOST_SYNC_DETAIL_POSIX_MUTEXES_TIMED_MUTEX_HPP_INCLUDED_
#include <time.h>
+#include <cstddef>
#include <boost/assert.hpp>
#include <boost/throw_exception.hpp>
#include <boost/utility/enable_if.hpp>
@@ -110,14 +111,14 @@
#else // defined(PTHREAD_MUTEX_INITIALIZER)
timed_mutex()
{
- int const res = pthread_mutex_init(&m_mutex, 0);
+ int const res = pthread_mutex_init(&m_mutex, NULL);
if (res)
{
BOOST_THROW_EXCEPTION(resource_error(res, "boost:: timed_mutex constructor failed in pthread_mutex_init"));
}
#if !defined(BOOST_SYNC_DETAIL_PTHREAD_HAS_TIMEDLOCK)
- int const res2 = pthread_cond_init(&m_cond, 0);
+ int const res2 = pthread_cond_init(&m_cond, NULL);
if (res2)
{
BOOST_THROW_EXCEPTION(resource_error(res, "boost:: timed_mutex constructor failed in pthread_cond_init"));
Copied and modified: trunk/boost/sync/detail/posix/semaphore.hpp (from r85674, trunk/boost/sync/semaphore/semaphore_posix.hpp)
==============================================================================
--- trunk/boost/sync/semaphore/semaphore_posix.hpp Sun Sep 15 07:05:46 2013 (r85674, copy source)
+++ trunk/boost/sync/detail/posix/semaphore.hpp 2013-09-15 12:58:33 EDT (Sun, 15 Sep 2013) (r85679)
@@ -7,52 +7,59 @@
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_SYNC_SEMAPHORE_SEMAPHORE_POSIX_HPP
-#define BOOST_SYNC_SEMAPHORE_SEMAPHORE_POSIX_HPP
+#ifndef BOOST_SYNC_DETAIL_POSIX_SEMAPHORE_HPP_INCLUDED_
+#define BOOST_SYNC_DETAIL_POSIX_SEMAPHORE_HPP_INCLUDED_
#include <semaphore.h>
#include <boost/assert.hpp>
-#include <boost/thread/exceptions.hpp>
+#include <boost/throw_exception.hpp>
+#include <boost/sync/detail/config.hpp>
+#include <boost/sync/exceptions/resource_error.hpp>
#ifdef BOOST_SYNC_USES_CHRONO
#include <boost/chrono/system_clocks.hpp>
#include <boost/chrono/ceil.hpp>
#endif
+#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 semaphore
{
BOOST_DELETED_FUNCTION(semaphore(semaphore const&))
BOOST_DELETED_FUNCTION(semaphore& operator=(semaphore const&))
public:
- semaphore(int i=0)
+ explicit semaphore(unsigned int i = 0)
{
- BOOST_ASSERT_MSG(i >= 0, "boost::sync::semaphore constructor called with negative count");
-
- const int status = sem_init(&sem, 0, i);
+ const int status = sem_init(&m_sem, 0, i);
if (status)
- boost::throw_exception(thread_resource_error(status, "boost::sync::semaphore constructor failed in sem_init"));
+ BOOST_THROW_EXCEPTION(resource_error(status, "boost::sync::semaphore constructor failed in sem_init"));
}
~semaphore()
{
- const int status = sem_destroy(&sem);
- (void)status;
- BOOST_ASSERT(!status);
+ BOOST_VERIFY(sem_destroy(&m_sem) == 0);
}
void post()
{
- const int status = sem_post(&sem);
+ const int status = sem_post(&m_sem);
switch (status)
{
case EOVERFLOW:
- boost::throw_exception(thread_resource_error(status, "boost::sync::semaphore post failed: Maximum allowable value would be exceeded"));
+ BOOST_THROW_EXCEPTION(resource_error(status, "boost::sync::semaphore post failed: Maximum allowable value would be exceeded"));
break;
case EINVAL:
@@ -67,7 +74,7 @@
{
for (;;)
{
- const int status = sem_wait(&sem);
+ const int status = sem_wait(&m_sem);
if (status == 0)
return;
@@ -87,7 +94,7 @@
bool try_wait(void)
{
- const int status = sem_trywait(&sem);
+ const int status = sem_trywait(&m_sem);
if (status == 0)
return true;
@@ -138,8 +145,9 @@
private:
bool do_wait_lock_until(struct timespec const & timeout)
{
- for (;;) {
- const int status = sem_timedwait(&sem, &timeout);
+ for (;;)
+ {
+ const int status = sem_timedwait(&m_sem, &timeout);
if (status == 0)
return true;
@@ -163,10 +171,15 @@
#endif // BOOST_SYNC_USES_CHRONO
private:
- sem_t sem;
+ sem_t m_sem;
};
-}
-}
+} // namespace posix
+
+} // namespace sync
+
+} // namespace boost
+
+#include <boost/sync/detail/footer.hpp>
-#endif /* BOOST_SYNC_SEMAPHORE_SEMAPHORE_POSIX_HPP */
+#endif // BOOST_SYNC_DETAIL_POSIX_SEMAPHORE_HPP_INCLUDED_
Copied and modified: trunk/boost/sync/detail/windows/semaphore.hpp (from r85674, trunk/boost/sync/semaphore/semaphore_win32.hpp)
==============================================================================
--- trunk/boost/sync/semaphore/semaphore_win32.hpp Sun Sep 15 07:05:46 2013 (r85674, copy source)
+++ trunk/boost/sync/detail/windows/semaphore.hpp 2013-09-15 12:58:33 EDT (Sun, 15 Sep 2013) (r85679)
@@ -6,16 +6,25 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_SYNC_SEMAPHORE_SEMAPHORE_WIN32_HPP
-#define BOOST_SYNC_SEMAPHORE_SEMAPHORE_WIN32_HPP
+#ifndef BOOST_SYNC_DETAIL_WINDOWS_SEMAPHORE_HPP_INCLUDED_
+#define BOOST_SYNC_DETAIL_WINDOWS_SEMAPHORE_HPP_INCLUDED_
+#include <cstddef>
+#include <limits>
#include <boost/detail/win/GetLastError.hpp>
#include <boost/detail/win/synchronization.hpp>
#include <boost/detail/win/handles.hpp>
+#include <boost/throw_exception.hpp>
+#include <boost/sync/detail/config.hpp>
+#include <boost/sync/exceptions/resource_error.hpp>
+#include <boost/sync/detail/header.hpp>
-#include <boost/typeof/typeof.hpp>
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
namespace boost {
+
namespace sync {
class semaphore
@@ -29,39 +38,44 @@
typedef boost::detail::win32::BOOL_ BOOL_;
public:
- semaphore(int i=0)
+ explicit semaphore(unsigned int i = 0)
{
- BOOST_ASSERT_MSG(i >= 0, "boost::sync::semaphore constructor called with negative count");
-
- sem_ = boost::detail::win32::CreateSemaphoreA(NULL, i, (std::numeric_limits<LONG_>::max)(), NULL);
- if (!sem_)
- boost::throw_exception(thread_resource_error(boost::detail::win32::GetLastError(), "boost::sync::semaphore constructor failed in CreateSemaphore"));
+ m_sem = boost::detail::win32::CreateSemaphoreA(NULL, i, (std::numeric_limits<LONG_>::max)(), NULL);
+ if (!m_sem)
+ {
+ const DWORD_ err = boost::detail::win32::GetLastError();
+ BOOST_THROW_EXCEPTION(resource_error(err, "boost::sync::semaphore constructor failed in CreateSemaphore"));
+ }
}
~semaphore()
{
- boost::detail::win32::CloseHandle(sem_);
+ boost::detail::win32::CloseHandle(m_sem);
}
void post()
{
- const BOOL_ status = boost::detail::win32::ReleaseSemaphore(sem_, 1, NULL);
+ const BOOL_ status = boost::detail::win32::ReleaseSemaphore(m_sem, 1, NULL);
if (status == 0)
- boost::throw_exception(thread_resource_error(boost::detail::win32::GetLastError(), "boost::sync::semaphore::post failed in ReleaseSemaphore"));
+ {
+ const DWORD_ err = boost::detail::win32::GetLastError();
+ BOOST_THROW_EXCEPTION(resource_error(err, "boost::sync::semaphore::post failed in ReleaseSemaphore"));
+ }
}
bool wait()
{
- using namespace boost::detail::win32;
-
- switch ( WaitForSingleObject(sem_, INFINITE) )
+ switch (boost::detail::win32::WaitForSingleObject(m_sem, boost::detail::win32::infinite))
{
- case wait_object_0:
+ case boost::detail::win32::wait_object_0:
return true;
- case wait_failed:
- boost::throw_exception(thread_resource_error(boost::detail::win32::GetLastError(), "boost::sync::semaphore::wait failed in WaitForSingleObject"));
+ case boost::detail::win32::wait_failed:
+ {
+ const DWORD_ err = boost::detail::win32::GetLastError();
+ BOOST_THROW_EXCEPTION(resource_error(err, "boost::sync::semaphore::wait failed in WaitForSingleObject"));
+ }
default:
BOOST_ASSERT(false);
@@ -95,18 +109,19 @@
#ifdef BOOST_SYNC_USES_CHRONO
bool do_try_wait_for( long milliseconds )
{
- using namespace boost::detail::win32;
-
- switch ( WaitForSingleObject(sem_, milliseconds) )
+ switch (boost::detail::win32::WaitForSingleObject(m_sem, milliseconds))
{
- case wait_object_0:
+ case boost::detail::win32::wait_object_0:
return true;
- case wait_timeout:
+ case boost::detail::win32::wait_timeout:
return false;
- case wait_failed:
- boost::throw_exception(thread_resource_error(boost::detail::win32::GetLastError(), "boost::sync::semaphore::do_try_wait_for failed in WaitForSingleObject"));
+ case boost::detail::win32::wait_failed:
+ {
+ const DWORD_ err = boost::detail::win32::GetLastError();
+ BOOST_THROW_EXCEPTION(resource_error(err, "boost::sync::semaphore::do_try_wait_for failed in WaitForSingleObject"));
+ }
default:
BOOST_ASSERT(false);
@@ -115,10 +130,13 @@
}
#endif
- HANDLE_ sem_;
+ HANDLE_ m_sem;
};
-}
-}
+} // namespace sync
+
+} // namespace boost
+
+#include <boost/sync/detail/footer.hpp>
-#endif // BOOST_SYNC_SEMAPHORE_SEMAPHORE_WIN32_HPP
+#endif // BOOST_SYNC_DETAIL_WINDOWS_SEMAPHORE_HPP_INCLUDED_
Modified: trunk/boost/sync/semaphore.hpp
==============================================================================
--- trunk/boost/sync/semaphore.hpp Sun Sep 15 12:56:43 2013 (r85678)
+++ trunk/boost/sync/semaphore.hpp 2013-09-15 12:58:33 EDT (Sun, 15 Sep 2013) (r85679)
@@ -6,8 +6,8 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_SYNC_SEMAPHORE_HPP
-#define BOOST_SYNC_SEMAPHORE_HPP
+#ifndef BOOST_SYNC_SEMAPHORE_HPP_INCLUDED_
+#define BOOST_SYNC_SEMAPHORE_HPP_INCLUDED_
#ifdef BOOST_SYNC_DETAIL_DOXYGEN
@@ -23,7 +23,7 @@
* \b Throws: if an error occurs.
*
* */
- semaphore(int initial_count = 0);
+ explicit semaphore(unsigned int initial_count = 0);
/**
* \b Precondition: No thread is waiting on the semaphore
@@ -74,10 +74,10 @@
bool try_wait_until(const TimePoint & timeout);
};
+}
+}
-}}
-
-#else
+#else // BOOST_SYNC_DETAIL_DOXYGEN
#include <boost/sync/detail/config.hpp>
@@ -85,26 +85,54 @@
#pragma once
#endif
-#include <boost/sync/detail/header.hpp>
+#ifdef BOOST_HAS_UNISTD_H
+#include <unistd.h>
+#if (_POSIX_SEMAPHORES - 0) >= 200112L
+#define BOOST_SYNC_DETAIL_USE_POSIX_SEMAPHORES
+#endif
-#if defined(BOOST_THREAD_PLATFORM_WIN32)
-#include <boost/sync/semaphore/semaphore_win32.hpp>
+#endif // BOOST_HAS_UNISTD_H
-#elif defined(BOOST_THREAD_POSIX_SEMAPHORES)
-#include <boost/sync/semaphore/semaphore_posix.hpp>
+#if !defined(BOOST_SYNC_DETAIL_USE_POSIX_SEMAPHORES) && defined(__APPLE__)
+#include <Availability.h>
-#elif defined(BOOST_THREAD_DISPATCH_SEMAPHORES)
-#include <boost/sync/semaphore/semaphore_dispatch.hpp>
+// OSX
+#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
-#else
+#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
-#include <boost/sync/semaphore/semaphore_emulation.hpp>
+// 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
-#include <boost/sync/detail/footer.hpp>
+#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/windows/semaphore.hpp>
+
+#elif defined(BOOST_SYNC_DETAIL_USE_POSIX_SEMAPHORES)
+#include <boost/sync/detail/posix/semaphore.hpp>
+
+#elif defined(BOOST_SYNC_DETAIL_USE_DISPATCH_SEMAPHORES)
+#include <boost/sync/detail/darwin/semaphore.hpp>
+
+#else
+#include <boost/sync/detail/generic/semaphore.hpp>
#endif
-#endif // BOOST_THREAD_SEMAPHORE_HPP
+#endif // BOOST_SYNC_DETAIL_DOXYGEN
+
+#endif // BOOST_SYNC_SEMAPHORE_HPP_INCLUDED_
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